Solved

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

Posted on 2010-09-21
2
378 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:
ScottPletcher earned 500 total points
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now