Index rebuild before table update

  • There is some front end code that insert around 40000+ rows into a table then runs an update to all columns on all the rows.

    Would it be okay after the insert to do an index rebuild before the update?

    So i would create a sproc which first rebuilds indexes then runs the update command?

  • bugg (3/21/2013)


    Would it be okay after the insert to do an index rebuild before the update?

    Is the index rebuild necessary?

    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 (3/21/2013)


    bugg (3/21/2013)


    Would it be okay after the insert to do an index rebuild before the update?

    Is the index rebuild necessary?

    Possibly not its, the index at 97% fragmented after the insert though. So i thought a rebuild would help speed up the update.

  • It might. Test it, test a stats update and see which if either makes a noticable difference

    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
  • With limited insight into the overall process this may sound like I am asking a silly question so forgive me please, but why not push all the necessary data changes to the table in the INSERT? i.e. why INSERT 40K rows then turn around and immediately update them all?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 5 posts - 1 through 4 (of 4 total)

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