Sample Header Ad - 728x90

SORT(DISTINCT) :Is it because of Kitchen sink queries?

2 votes
0 answers
275 views
One of the SQL queries I am working on is slow in performance. I have been trying to fix it for the last two days, unsuccessfully. The query is generated from an application (Linq to sql -EFF), and based on the user search criteria, it passes parameters to the query. I looked into the execution plan and I see sort operations. One of the sort operation is SORT(DISTINCT). I checked the query and I found some order by in the query. Removing order by didn't help, and I dont have a DISTINCT in the query. On checking the properties of the SORT(DISTINCT) it is not showing the field on which it is doing sort. I have attached the screenshot of that. After doing some research I learned that OR in where conditions can generate SORT operations as the MERGE required some kind of sort, and I do have OR in where conditions which looks like: where (column1 = @param1) OR (column1 IS NULL) OR (@param1 IS NULL) Someone suggested me in an earlier post that, this are "Kitchen sink" queries and it will cause performance issues. Is there anyone who had to deal with similar situation? Any solutions? SORT(DISTINCT)
Asked by user9516827 (1345 rep)
Jun 22, 2018, 03:39 PM
Last activity: May 8, 2022, 07:20 PM