문제

I read the following statements in sybase guide which seem to be contradicting. Since I am a newbie in database tuning ,would appreciate any help in reconciling these.

1.If your environment requires a lot of inserts, do not place the clustered index key on a steadily increasing value such as an IDENTITY column.

2.Clustered indexes provide very good performance when the key matches the search argument in range queries, such as: where colvalue >= 5 and colvalue < 10

도움이 되었습니까?

해결책

These statements do not contradict each other.

The first statement deals with INSERTS into a table. If you have an autoincrementing IDENTITY column, the clustered index adds overhead without a lot of benefit. (Remember that the clustered index keeps the data in order based on the index key...if your index key is an IDENTITY column, then it's already kept in order)

The second statment deals with SEARCHES. When retrieving data for read/update, the indexes can improve the performance, if the search key matches the clustered index.

This is why it's important to have an understanding about what kind of activity you expect to see in your database to understand if you need to tune for inserts, updates or searches, as that will affect whether you will use Clustered versus Non-Clustered indexes or combinations thereof.

다른 팁

That's because if you create a clustered index on identity column, the inserts will happen one page only. If there are multiple processes then the processes will just block each other as each will try to get a LOCK on that last page.

One of the advantages of clustered index is that they spread the INSERTS across the table, which is of great advantage in preventing blocking in such an multi-process environment.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top