Order by first before creating a clustered index??

  • Does anyone know if it's faster to do "order by" before creating a clustered index?

    ex)

    select COLUMN_A, max(COLUMN_B) as COLUMN_B

    into TABLE_B

    from TABLE_A

    group by COLUMN_A

    order by COLUMN_A

    create unique clustered index COLUMN_A on TABLE_B (COLUMN_A)

    Thanks.

  • Max (2/13/2009)


    Does anyone know if it's faster to do "order by" before creating a clustered index?

    ex)

    select COLUMN_A, max(COLUMN_B) as COLUMN_B

    into TABLE_B

    from TABLE_A

    group by COLUMN_A

    order by COLUMN_A

    create unique clustered index COLUMN_A on TABLE_B (COLUMN_A)

    Thanks.

    No. Running the query above prior to creating the clustered index will have no affect at all on the create index statement.

  • Lynn Pettis (2/13/2009)


    No. Running the query above prior to creating the clustered index will have no affect at all on the create index statement.

    Actually won't it slow everything down? I mean not the actual creation of the index itself, but the process.

    "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

  • What I think he was asking, will the create index run faster after I run the query with the order by first.

    If that isn't what the OP meant, he needs to do a better job of explaining his request.

  • Lynn Pettis (2/13/2009)


    What I think he was asking, will the create index run faster after I run the query with the order by first.

    If that isn't what the OP meant, he needs to do a better job of explaining his request.

    No, you got it right I think. I just wanted to point out that the wasted effort wasn't zero sum, it not only didn't help, it hurt overall. Sorry, I did it in too flippant a way.

    "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

  • Actually, I think we need an emoticon for sarcism. Know of one?

  • I would have to vote for this one.

    :Whistling:

Viewing 7 posts - 1 through 6 (of 6 total)

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