Clustered indexes on non-identity columns to speed up bulk inserts?

后端 未结 6 569
名媛妹妹
名媛妹妹 2020-12-10 16:16

My two questions are:

  • Can I use clustered indexes to speed up bulk inserts in big tables?
  • Can I then still efficiently use foreign key relationships i
6条回答
  •  遥遥无期
    2020-12-10 16:40

    Well, I've put it to the test, and putting a clustered index on the two "chunk-defining" columns increases the performance of my table.

    Inserting a chunk is now relatively fast compared to the situation where I had a clustered IDENTITY key, and about as fast as when I did not have any clustered index. Deleting a chunk is faster than with or without clustered index.

    I think the fact that all the records I want to delete or insert are guaranteed to be all together on a certain part of the harddisk makes the tables faster - it would seem logical to me.


    Update: After a year of experience with this design I can say that for this approach to work, it is necessary to schedule regular rebuilding of all the indexes (we do it once a week). Otherwise, the indexes become fragmented very soon and performance is lost. Nevertheless, we are in a process of migration to a new database design with partitioned tables, which is basically better in every way - except for the Enterprise Server license cost, but we've already forgotten about it by now. At least I have.

提交回复
热议问题