• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

clustered and nc index on same columns- is that harmless

it makes no sense, but the prev designer has a clus index and also nc index on the same set of columns on a table. but is this harmless or can it cause problems..

the reason i ask is that the index was corrupted in this table.. could it have been because of the above fact?

(there are duplicates that should have never gotten in )
0
25112
Asked:
25112
2 Solutions
 
Mark WillsTopic AdvisorCommented:
Well, cant say that I have done that before, but yes, it is harmless.

It will always maintain the clustered index first, then the NC index gets updated (because the nc index will use the clustered index key to point to data).

Bigger problems is probably those dupes :)

Dont normally use a clustered index on dupe values - it will add a uniquifier and creates a bit more overheads.

Are there any queries or procedures or scripts currently using specific index hints ? If not, then time to tidy up.

While it might be harmless, I would definitely remove the NC index - assuming the clustered index serves a higher purpose.

Do you have a unique index on that table ? If so, would be inclined to use that as your clustered index and then add in the other NC indexes afterwards.
0
 
Scott PletcherSenior DBACommented:
Using the same columns for two (or more) indexes won't cause any errors.  The index corruption was caused by something else.

This set up can even be legimitately useful in specific cases, primarily when no other n-c indexes exist on that table.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now