Sort operation in execution plan

  • 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 ?

  • 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?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thanks for your answer. let me look and come with necessary details.

  • 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

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply