I have a convoluted MSSQL 2008 query, and the show plan has 40% of the work in a sort operation (there are several mil rows and the query does a top 15000), the rest of the plan is index seeks and scans.
If I remove the TOP
clause, the query goes down to a second. But I need the TOP
. What are some rules of thumb for smartly optimizing this SORT need?