?
Solved

unable to rebuild an Index SQL 2008 R2

Posted on 2013-06-20
5
Medium Priority
?
442 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:
Scott Pletcher earned 1000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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, …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 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