8
u/LurkerNumber44 May 31 '22
lolz. i can't wait to see what Brent says.
1
u/kagato87 Jun 01 '22
Brent would probably figure out a way to make that synthetic query run...
4
u/ArtooSA Jun 01 '22
It's not a case of fixing the query, rather a complete rewrite. The developer basically threw a whole bunch of random left joins together, with a distinct to remove the excess. I actually needed to use a defibrillator on tempdb after that 😅
1
1
u/ArtooSA Jun 01 '22
It's not a case of fixing the query, rather a complete rewrite. The developer basically threw a whole bunch of random left joins together, with a distinct to remove the excess. I actually needed to use a defibrillator on tempdb after that 😅
3
2
u/FriendlyDisorder Jun 01 '22
The SQL Server query optimizer does a great job 99% of the time. The remaining 1% keeps me employed. 😏
3
u/ArtooSA Jun 01 '22
Query optimiser cannot optimise this particular junior developer. He joined 10 tables on random columns (recursive Cartesian products) and didn't get the expected results. So he made them all left joins, effectively removing any filters, and did a distinct.
He actually complained that I didn't configure tempdb correctly when his query failed because tempdb ran out of space.
1
u/FriendlyDisorder Jun 01 '22
Ha! Great story. I have had the same experience before. Nothing can defeat the power of the Junior Developers-- not even the mighty Query Optimizer!
3
u/phunkygeeza Jun 01 '22
Good job that is a parallel query, should only take a few years instead of a millennium or so.
2
1
u/dblue_one Jun 01 '22
Dev that made that query deserves a email spam, half that number should be enough.
0
4
u/messed_up_alligator May 31 '22
Is that estimate accurate? Sweet jesus lol. After a distinct at that
If it's not accurate, any clues to what the query looked like to get such a large overestimate?