May 10, 2011 at 3:36 am
I am able to create Cluster and Non clustered index on same Column of same table.
Which index will get the prority and why?
create index IX__table_1 on table_1(a)
create clustered index IXcluster__table_1 on table_1(a)
Thanks
May 10, 2011 at 3:52 am
Depends completely on the query.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 10, 2011 at 5:50 am
Note it when you create the Cluster index then non-clustered index on the same table will be drop and then recreate autmatically
It depends on the query you have provide if you create first non-clustered index then non-clustered index will be create first but then you create a clustered index on the same table then non-clustered indexes will be drop and recreate after clustered index created
Regards,
Syed Jahanzaib Bin Hassan
BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
www.aureus-salah.com
May 10, 2011 at 6:00 am
I'd also add than if a WHERE statement is included in the command, that is used by the optimizer to decide which index will be used to retrieve the data.
If an index exists on say, the LastName column, and you have a WHERE statement like WHERE LastName = 'Shaw', that index would most likely be sued(you need to see the execution plan to be sure.
if you search on a column that does not have an index, or use a non-SARG-able argument,then a table scan will occur, once again based on whatever index the optimizer thinks is best to look for the data with...most likely the clustered index
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply