Rebuild Indexes

  • Hello Everyone

    I am rebuilding the indexes on a database every week. I am getting complaints that the database is being locked during this process, and failing some transactions. Is there any to rebuild all the indexes and not lock the database? The entire process takes approx 30 - 40 mins.

    Thank you in advance for your suggestions, comments and time

    Andrew SQLDBA

  • If you have Enterprise Edition, you can rebuild the indexes online, they'll probably take longer but don't hold long-duration locks.

    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
  • is it a 24/7 avail db? Then you'll have to pay for Enterprise Edition for the ONLINE = ON option. If not, can you do if off-hours? I do mine on Sunday mornings at 7am.

    Otherwise, just do reorgs instead of full rebuilds. Better than nothing.

  • Are you rebuilding every index? Maintenance Plans do this.

    Consider using a tool that inspects the fragmentation levels and only rebuilds indexes that actually need it. Here is a good one: http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

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

  • opc.three (5/6/2013)


    Are you rebuilding every index? Maintenance Plans do this.

    Consider using a tool that inspects the fragmentation levels and only rebuilds indexes that actually need it. Here is a good one: http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

    +1 vote for this.

    To the OP ... try to implement Ola's solution and pick a date with few or no connections. It will be impossible to find a perfect time but at least, a night or day with very little activity.

    The beauty of Ola's solution, is that it is "smart". It lets you tweak or customize the rebuild options and you can skip tables with less than 1k pages, or customize your own.

    I have a 1.5TB database and the job only takes 55 minutes. Initial run was painfully slow though, almost 12 hrs, but after that, that's all it takes.

  • Yes, I have already done all of that. I did choose a time with the least amount of connections. There is one that comes from a java source that is open all the time. This one pumps data in at an almost constant basis. This is the one that I am having difficulty with. I have already chosen only the tables and indexes are large. I am not performing this on tables that never change or that are fragmented below a set percentage.

    Thank you to everyone that replied

    Andrew SQLDBA

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

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