Solved

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

Posted on 2010-09-21
2
425 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

733 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