Solved

unable to rebuild an Index SQL 2008 R2

Posted on 2013-06-20
5
433 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:
Scott Pletcher 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scheduling Jobs for Execution: 4 23
Usage Scenarios for Extended Events? 1 25
SQL Exceptions 3 40
create insert script based on records in a table 4 16
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 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

19 Experts available now in Live!

Get 1:1 Help Now