I'm working in Sql Server 2005. I have an event log table that tracks user actions, and I want to make sure that inserts into the table are as fast as possible. Currently the table doesn't have any indexes. Does adding a single non-clustered index slow down inserts at all? Or is it only clustered indexes that slow down inserts? Or should I just add a clustered index and not worry about it?
Indexes, clustered or non-clustered,will always slow down inserts as SQL has to maintain both the table and index. This slowdown is in an "absolute" sense and you may not notice it. I would add whatever indexes are necessary to retrieve your data.
Yes, any index will take a little bit of time to keep up to date when doing INSERT, UPDATE, DELETE
operations. The more indices you have, the more time we're talking about.
But ultimately it depends on what's more important to you - good query performance (then add indices as needed), or good insert performance (then have as few indices as possible).
Which operation do you perform more often??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With