Questions tagged [sort-operator]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
3 answers
386 views

Getting a SORT operator when I have an index

On a Azure SQL db (SQL2019 compat), I have an ETL process that populates HISTORY tables in a DeltaTrack pattern. In the Proc, there's an UPDATE to the HISTORY table which the query engine is using a ...
Geezer's user avatar
  • 441
0 votes
1 answer
61 views

What makes the optimizer insert a sort operator in the plan

What are the reasons that the optimizer chooses to insert a sort operator in the plan (to satisfy a stream aggregate or a merge join, etc.) instead of going for hash match or hash join? I have now see ...
xhr489's user avatar
  • 805
1 vote
1 answer
32 views

Azure SQL Server - Cannot get rid of the sort operator

I'm using Azure SQL Server (Microsoft SQL Azure (RTM) - 12.0.2000.8 Apr 3 2019 13:27:00 Copyright (C) 2019 Microsoft Corporation), Premium tier 4 (500 DTUs). Query: offer progress has a history ...
Francisco Goldenstein's user avatar
43 votes
2 answers
3k views

Why does changing the declared join column order introduce a sort?

I have two tables with identically named, typed, and indexed key columns. One of the them has a unique clustered index, the other one has a non-unique. The test setup Setup script, including some ...
Daniel Hutmacher's user avatar
2 votes
0 answers
260 views

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

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 ...
user9516827's user avatar
  • 1,305
1 vote
1 answer
676 views

Poor performance by LINQ to SQL generated query execution plan

Can you please check the attached execution plan from my SQL Server 2016 and suggest me where to improve. The query is generated from the .Net application using LINQ to SQL. I can see large sort ...
user9516827's user avatar
  • 1,305
4 votes
2 answers
1k views

left outer join - sort operations in the query plan - any ways of tuning this simple query?

while working on the query below in order to answer this question: How to query chart data in a database agnostic way? Having the following tables: CREATE TABLE [dbo].[#foo] ( [creation] DATETIME ...
Marcello Miorelli's user avatar
2 votes
1 answer
212 views

How can I update statistics adding the data of the last day only?

I have been tuning some queries that had a warning on the sort operator, which is generally an expensive operator: Operator used tempdb to spill data during execution with spill level 2 The way to ...
Marcello Miorelli's user avatar
25 votes
1 answer
29k views

Operator used tempdb to spill data during execution with spill level 2

I am struggling to minimise the cost of sort operation on a query plan with the warning Operator usedtempdbto spill data during execution with spill level 2 I have found several posts related to ...
Marcello Miorelli's user avatar
1 vote
2 answers
4k views

Estimated Execution Plan SQL Server Sort?

I'm running a query and its taking a age to execute, looking at the execution plan I can see that 51% of the cost is in the SORT? when in the actual query i am not ORDERING BY anything. Anyone got ...
user avatar