Solved

unable to rebuild an Index SQL 2008 R2

Posted on 2013-06-20
5
432 Views
Last Modified: 2013-06-27
Hi,
I need some quick (I hope quick ) help on an issue we are having with a live SQL 2008 R2 database.
we have a table with about 40 GB of data and several indexes, these indexes are not at all optimized but we are unable to recreate or rebuild one of the indexes, it is a primary key index and is causing big issues with running reports off of this table.
any help would be appreciated.
0
Comment
Question by:atorex
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:COANetwork
ID: 39262248
What error are you getting, specifically?  If you have a clustered PK - check out this resource: http://www.mssqltips.com/sqlservertip/1362/efficiently-rebuild-sql-server-clustered-indexes-with-dropexisting/
Make sure you have enough memory and disk space for the operation.  If Sort in TempDB is enabled - make sure tempdb has enough disk space to grow and is configured for unlimited growth.
0
 

Author Comment

by:atorex
ID: 39262312
Thats one of the issues is that there are no errors in the log and the process never completes, I have a backup in the lab and running the recreate script has been running for 24 hours so far this process used to take less than 20 minutes.
To your point though we did notice that the tempDB had grown to about 15GB so I will have that looked at ad see if we can change the file growth limit and see if that helps or not.
0
 
LVL 9

Expert Comment

by:COANetwork
ID: 39263733
remove the limit.  also, if the table is being used, your rebuid will be ridiculously slow.  so try to do this in single-user mode, if possible.
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 500 total points
ID: 39263827
You need to pre-allocate enough log space, on both the main database and tempdb,  to handle this rebuild.

It will take SQL a while to pre-format that much log space, but it's nothing like the time it takes it to do when a log must grow dynamically during a REBUILD (or DELETE or INSERT or UPDATE).

Presumably you have IFI turned on: if not, (1) turn it on now! or (2) pre-allocate enough new data space as well.

It's incredible how much time pre-formatting enough log space can save on a rebuild such as this.

You may be able to rebuild the index online -- unless certain conditions apply -- which allows the table to remain fully in use, but does somewhat slow down the rebuild.
0
 

Author Closing Comment

by:atorex
ID: 39281856
I backed up the table and recreated a new table with the Pk index, put the data back and all is good now.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now