Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What was your coolest SQL optimization, on a slow performing query?

Just speaking to a colleague of mine. He was walking with a hop in his step, on the way to the coffee machine.

I asked him "what's with the 'swarmy' walk?", he said, "I just reduced a two hour long query down to 40 seconds! It feels so good".

He altered a stored procedure, that was using cursors and introduced a temp table, that was refactored from the original dataset - I will email him soon, to get more info on actual implemetation.

But ultimately, he was buzzing.

Question is, what SQL, that sticks in your mind and has made you buzz, whilst optimising slow performing queries?

like image 970
Ferdeen Avatar asked Mar 31 '09 13:03

Ferdeen


2 Answers

I have to say when I learned how to create and use covered indexes. Now, THAT was a performance booster.

like image 185
Otávio Décio Avatar answered Nov 13 '22 07:11

Otávio Décio


Using SQL's BULKIMPORT to reduce several hours of inherited INSERT code to less than a minute.

like image 37
David Avatar answered Nov 13 '22 06:11

David