Solved

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

Posted on 2010-09-21
2
401 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
2 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

786 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