Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

unable to rebuild an Index SQL 2008 R2

Posted on 2013-06-20
5
Medium Priority
?
446 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 70

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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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