This is related query tuning. I have a query which is doing expensive sorting. Without ORDER BY clause the query is returning the result set very fast when compared with having an ORDER BY DESC clause. Is there a way to avoid sorting from db side and suppose if the developer is so adamant and not listening for remove the ORDER BY clause. Is there an alternative way so that we can eliminate the sort operator in the execution plan.
Attaching the plan. Please share your thoughts.link text
By Maahi 1 asked Dec 21, 2017 at 07:15 PM
So I've looked at the execution plans. They are estimated plans, not actual plans, so they don't show the work actually done.
However, the plans show the exact same plan with the addition of a sort operator. (Might sound obvious to you but it's not - adding an ORDER BY can result in the optimizer picking a completely different execution plan). And they show an estimated row count of 7. There is no way that sorting 7 rows will ever take more than just a few milliseconds.
If you see much bigger performance issues than that, then please post the ACTUAL execution plans and I'll see what they show.
By Hugo Kornelis 211 answered Dec 21, 2017 at 07:27 PM