?
Solved

will there be a dataloss doing rebuild index instead of reorg index?

Posted on 2010-09-21
2
Medium Priority
?
438 Views
Last Modified: 2012-05-10
Hi All,
will there be a dataloss doing rebuild index instead of reorg index?
if not, then what is teh use of prefering reorg instead of rebuild?
0
Comment
Question by:saratcm
[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 Comments
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 2000 total points
ID: 33730097
No, SQL will never allow a data loss with any command.

Which is preferred actually depends on the condition of the index(es).  [If there are no indexes, neither rebuild nor reorg apply at all anyway.]

If the index is only slightly fragmented, say from 10-30% [you will see some recommendations as low as 20%, or as high as 40%], then you can do a reorg.  A reorg is always done live, so the table can be used by others while it is being reorg'ed.  The reorg is done is small chunks and so does not have a major impact on log size either.  A reorg does not fully defragment the index but it does some logical defragmentation.

Conversely, a rebuild of a clus index requires SQL to lock the table until the operation is complete [unless you have the Enterprise version, specify ONLINE rebuild, and meet the criteria for an ONLINE rebuild].  But a rebuild completely rebuilds the index, restoring the FILLFACTOR and removing all unrequired pages (if, for example, lots of rows have been deleted).

Rebuilding a nonclustered index also requires a table lock unless you specify ONLINE; the table will be locked while the nonclus index is being rebuilt.

"Locked" means any row mods (insert/update/delete) are prevented for sure, as are column mods.  

I don't think you can even read the table, not even if you specify WITH (NOLOCK), but I'm not 100% sure of that.
0
 

Author Closing Comment

by:saratcm
ID: 33730376
Thanks
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

718 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