Overhead on a NC index if the key fields are not updated during production.

  • My next question while I am in the INDEX zone.

    As an example:

    I have a large table (4 - 5 million rows) and I have say five NC indexes on the fields being used in WHERE and JOIN clauses for the incoming queries.

    If their is never [or minimal] UPDATES on any of the fields in the NC clustered indexes (INCLUDE fields as well) then is it fair to say that their would only be minimal operational overhead related to updating the NC indexes?

    i.e UPDATES will happen very frequently to the data in the table but only on non NC indexed fields so only the Clustered index would need to be updated?

    I guess their will be other overhead of keeping these indexes INSERTS, query plan compilation, memory used etc?

    Obviously maintenance will need to be performed but I am talking about production hours activity.

    thanks

  • As far as I understand, unless the index is filtered, all inserts/updates/deletes will affect all nonclustered indexes.

    Think in a row level, not just on a field level

    EDIT - I might be and probably am wrong about the updates though.

  • pretty sure SQLSACT is correct;

    part of the update process is updating the indexes that are affected, so when the transaction is committed, bit the data itself and the indexes which point to the data are in sync;

    only statistics lag behind, and that can be a concern in high transaction situations.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Keep in mind that if you are changing the Clustering key at all with your updates, all nonclustered indexes will be affected as well

  • If you are never modifying any of the columns that are in the index, then the index has no update overhead. It'll still add overhead to inserts and deletes, but only updates that change columns in the index key/include have to touch the index.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • AFAIK, Gail is correct. If the columns in the NC index are not changed with an update, that index is not touched. No reason to, as there's nothing to update.

  • GilaMonster (7/3/2013)


    If you are never modifying any of the columns that are in the index, then the index has no update overhead. It'll still add overhead to inserts and deletes, but only updates that change columns in the index key/include have to touch the index.

    Hi Gail - Just to confirm, is this part correct?

    if you are changing the Clustering key at all with your updates, all nonclustered indexes will be affected as well

  • SQLSACT (7/4/2013)


    Hi Gail - Just to confirm, is this part correct?

    if you are changing the Clustering key at all with your updates, all nonclustered indexes will be affected as well

    The clustered index key is present in every single nonclustered index, just like any other column for the purposes of updates.

    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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (7/4/2013)


    SQLSACT (7/4/2013)


    Hi Gail - Just to confirm, is this part correct?

    if you are changing the Clustering key at all with your updates, all nonclustered indexes will be affected as well

    The clustered index key is present in every single nonclustered index, just like any other column for the purposes of updates.

    Thanks

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply