Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about ALTER INDEX... REBUILD

Status
Not open for further replies.

pandatime

Programmer
Jan 29, 2010
92
AU
Hi,

I am wanting to rebuild some indexes in my database. I have a script that will generate my ALTER INDEX... REBUILD statements for me in the following format, e.g.)

ALTER INDEX ALL ON myTable REBUILD

My question is, when SQL Server generates the drop and create statements internally when this run, will it specify the indexes be created in the SAME exact locations on disk?

I am assuming it would, but just want to be sure. Can't see to find any documentation on it.

Thanks!
 
I think it depends. I found the following statement:

Rebuilding Indexes
Rebuilding an index drops and re-creates the index. This removes fragmentation, reclaims disk space by compacting the pages based on the specified or existing fill factor setting, and reorders the index rows in contiguous pages. When ALL is specified, all indexes on the table are dropped and rebuilt in a single transaction. FOREIGN KEY constraints do not have to be dropped in advance. When indexes with 128 extents or more are rebuilt, the Database Engine defers the actual page deallocations, and their associated locks, until after the transaction commits. For more information, see Dropping and Rebuilding Large Objects.

Take a look at this site, if you haven't already:
 
Thanks. Nevermind.

This statement from BOL clarifies:

ALTER INDEX cannot be used to repartition an index or move it to a different filegroup.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top