Question

Running a very simple query:

SELECT TOP 10 *
FROM WH.dbo.vw_data m
ORDER BY DateCompleted

Takes around 4 minutes.

96% of the execution is taken up by the following:

enter image description here

What does the warning mean and how is it interpretted?

The field DateCompleted isn't indexed: does this mean unless we hit an alternative field with an index, or add an index to DateCompleted it will always be slow?

Was it helpful?

Solution

Definitely index DateCompleted. You can see from the execution plan that 96% of the cost occurs when sorting this field, therefore it makes sense to add an index.

CREATE NONCLUSTERED INDEX IX_DATE_COMPLETED
    ON YourTable (DateCompleted); 

OTHER TIPS

Sort Warnings are raised by SQL Server when a sort operation cannot be done in memory and must spill to tempdb

This article answers your question on Sort Warnings (link updated again, thanks to @quarkonium:

http://blogs.solidq.com/en/sqlserver/identifying-solving-sort-warnings-problems-sql-server/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top