Solved

unable to rebuild an Index SQL 2008 R2

Posted on 2013-06-20
5
436 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 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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