I have to pull tons data from multiple tables.
obviously I have something wrong.
It has been running for 15 minutes
Now with above code that must be really worst code..
So tempdb is filling up on drive.
If that's how to join the tables together you don't have anything wrong.
As for the slow query, ideally we need to actual execution plan to diagnose what is going on, but first places to start would be ensuring indexes, statistics are all created to support the query and up to date.
For the TempDB issue, the ORDER BY is killing it as all ORDER BY's are done in TempDB, so if you have a 8GB TempDB then your data result set sort is larger than 8. Try reducing the amount of data your bringing back with a where clause.
answered Sep 01, 2017 at 09:55 AM