I was shown this piece of SQL gems:
delete from bad_table where name not in (select name from good_table);
Then something like "it has always fast until now". So I straighten this code to:
delete from bad_table where name in
(select b.name from bad_table b, good_table g
where b.name = g.name(+) and g.name is null)
The first query was fast but is low now because bad_table has grown since the code went into production. Yay! outer join saves the day!
Friday, March 5, 2010
sizeof hurts me!
I should be sent back to cs101 (introduction to c programming) for writing shit like this recently:
My instinct tells me the "sizeof" above will return more than 4 but there a voice in me that says "nah, the compiler will sort it out". Wrong! *dope slap*
Somewhere along my programming trip, I thought I remember that sizeof is a smart function! Sort of like the pointer incremental operator... you know, how it will move to the correct memory location depending on the type... Oh well, I must be mixing c up with Pascal or something... too many programs and yet still too long to go before I'm asleep.
int matrix[] = { 1, 3, 7, 11};
int i;
for (i=0; i < sizeof(matrix); i++)
{
blah...blah...blah...;
}
My instinct tells me the "sizeof" above will return more than 4 but there a voice in me that says "nah, the compiler will sort it out". Wrong! *dope slap*
Somewhere along my programming trip, I thought I remember that sizeof is a smart function! Sort of like the pointer incremental operator... you know, how it will move to the correct memory location depending on the type... Oh well, I must be mixing c up with Pascal or something... too many programs and yet still too long to go before I'm asleep.
Subscribe to:
Posts (Atom)