Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sort operation in execution plan Expand / Collapse
Author
Message
Posted Wednesday, April 30, 2014 3:16 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 2:11 AM
Points: 336, Visits: 1,155
I have two set of tables
each table has unique Column and indexes.
while doing a Order by operation when i issue order by columns in one table i dont see any Sort operation cost(less than 15%), where as if i include second table column in the order by then the Sort operation cost is nearly 70%
so what might be the reason ?
Post #1566275
Posted Wednesday, April 30, 2014 3:27 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:28 AM
Points: 13,630, Visits: 11,501
Without any table DDL, index definitions, queries used and query plan we can only guess.

Maybe because in the first query data was already presorted by an index, while in the second query the index could not be used to sort the data and thus it had to do more work?




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1566278
Posted Wednesday, April 30, 2014 3:46 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 2:11 AM
Points: 336, Visits: 1,155
Thanks for your answer. let me look and come with necessary details.
Post #1566285
Posted Wednesday, April 30, 2014 5:04 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:17 AM
Points: 14,196, Visits: 28,520
Pretty sure Koen has nailed it already. The JOIN is likely to change the order in which data is retrieved, so a sort operation will be necessary.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server Query Performance Tuning
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1566310
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse