Re: How does CREATE INDEX impact current users?
From: Paul S Randal [MS] (prandal_at_online.microsoft.com)
Date: 05/15/04
- Next message: Tibor Karaszi: "Re: dbackupoperators"
- Previous message: Dan Guzman: "Re: questions about logging"
- In reply to: Michael Cheng [MSFT]: "RE: How does CREATE INDEX impact current users?"
- Next in thread: Danny J. Lesandrini: "Re: How does CREATE INDEX impact current users?"
- Reply: Danny J. Lesandrini: "Re: How does CREATE INDEX impact current users?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 15 May 2004 09:56:22 -0700
Here's the correct answer for you (Michael please take note).
Creating a non-clustered index will take an S lock on the table, thus
preventing all modifications to the table. Creating a clustered index will
take an X lock on the table, thus preventing any access to the table at all.
This problem is alleviated in SQL Server 2005 with the concept of online
index builds and rebuilds, where complete concurrent access to the data is
available during the index operation.
Creating a clustered index does not copy the table per se - the heap
contents are fed into a sort and the output of the sort is used to construct
the b-tree for the clustered index. Once complete the original heap is
discarded. In SQL Server 2000, you need approx 1.2x the original heap size
of free space to create the clustered index. The amount of transaction log
created should also be taken into account, and depends on your logging mode.
Please let me know if you have any additional questions.
Thanks and regards.
-- Paul Randal Dev Lead, Microsoft SQL Server Storage Engine This posting is provided "AS IS" with no warranties, and confers no rights. ""Michael Cheng [MSFT]"" <v-mingqc@online.microsoft.com> wrote in message news:lsrrgRlOEHA.3972@cpmsftngxa10.phx.gbl... > Hi Danny, > > Thanks for Alex's reply > > From your descriptions, I understood that you would like to make CREATE > INDEX and you are afraid of its possible impact on logged users. Have I > understood you? If there is anything I misunderstood, please feel free to > let me know :) > > Based on my knowledge, it will not lock your table when creating index on > it. However, when you create a clustered index, the table is copied, the > data in the table is sorted, and then the original table is deleted. > Therefore, enough empty space must exist in the database to hold a copy of > the data. And creating a unique index ensures that any attempt to duplicate > key values fails. > > As Alex suggested, it is strongly recommand to create your index at > midnight, which will do less impact on your production server. The > following documents will be helpful to you, which tell you how to build > index with less defragmentations and better performance:) > > Microsoft SQL Server 2000 Index Defragmentation Best Practices > http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx > > SQL Server Database Index Performance Checklist > http://www.sql-server-performance.com/sql_server_performance_audit7.asp > > SQL Server - Indexes and Performance > http://www.databasejournal.com/features/mssql/article.php/1467801 > > Moreover, you could find how an index works from Books Online or MSND Online > > tempdb and Index Creation > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ > ar_da2_5nou.asp > > Creating an Index > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm > _8_des_05_8185.asp > > Hope this helps and if you have any questions or concerns, don't hesitate > to let me know. We are here to be of assistance! > > Sincerely yours, > > Michael Cheng > Microsoft Online Support > *********************************************************** > Get Secure! - www.microsoft.com/security > This posting is provided "as is" with no warranties and confers no rights. > Please reply to newsgroups only, many thanks. > >
- Next message: Tibor Karaszi: "Re: dbackupoperators"
- Previous message: Dan Guzman: "Re: questions about logging"
- In reply to: Michael Cheng [MSFT]: "RE: How does CREATE INDEX impact current users?"
- Next in thread: Danny J. Lesandrini: "Re: How does CREATE INDEX impact current users?"
- Reply: Danny J. Lesandrini: "Re: How does CREATE INDEX impact current users?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|