[转]Guidelines for Online Index Operations

Online functionality

The underlying table cannot be modified, truncated, or dropped while an online index operation is in process.

The online option setting (ON or OFF) specified when you create or drop a clustered index is applied to any nonclustered indexes that must be rebuilt. For example, if the clustered index is built online by using CREATE INDEX WITH DROP_EXISTING, ONLINE=ON, all associated nonclustered indexes are re-created online also.

When you create or rebuild a UNIQUE index online, the index builder and a concurrent user transaction may try to insert the same key, therefore violating uniqueness. If a row entered by a user is inserted into the new index (target) before the original row from the source table is moved to the new index, the online index operation will fail.

Although not common, the online index operation can cause a deadlock when it interacts with database updates because of user or application activities. In these rare cases, the SQL Server Database Engine will select the user or application activity as a deadlock victim.

You can perform concurrent online index DDL operations on the same table or view only when you are creating multiple new nonclustered indexes, or reorganizing nonclustered indexes. All other online index operations performed at the same time fail. For example, you cannot create a new index online while rebuilding an existing index online on the same table.

An online operation cannot be performed when an index contains a column of the large object type, and in the same transaction there are update operations before this online operation. To work around this issue, place the online operation outside the transaction or place it before any updates in the transaction.

Disk Space Considerations    

Generally, disk space requirements are the same for online and offline index operations. An exception is additional disk space required by the temporary mapping index. This temporary index is used in online index operations that create, rebuild, or drop a clustered index. Dropping a clustered index online requires as much space as creating a clustered index online. For more information, see Disk Space Requirements for Index DDL Operations.

Performance Considerations     

Although online index operations permit concurrent user update activity, the index operations will take longer if the update activity is very heavy. Typically, online index operations will be slower than equivalent offline index operations regardless of the concurrent update activity level.

Because both the source and target structures are maintained during the online index operation, the resource usage for insert, update, and delete transactions is increased, potentially up to double. This could cause a decrease in performance and greater resource usage, especially CPU time, during the index operation. Online index operations are fully logged.

Although we recommend online operations, you should evaluate your environment and specific requirements. It may be optimal to run index operations offline. In doing this, users have restricted access to the data during the operation, but the operation finishes faster and uses fewer resources.

On multiprocessor computers that are running SQL Server 2012, index statements may use more processors to perform the scan and sort operations associated with the index statement just like other queries do. You can use the MAXDOP index option to control the number of processors dedicated to the online index operation. In this way, you can balance the resources that are used by index operation with those of the concurrent users. For more information, see Configure Parallel Index Operations. For more information about the editions of SQL Server that support Parallel indexed operations, see Features Supported by the Editions of SQL Server 2012 (http://go.microsoft.com/fwlink/?linkid=232473).

Because an S-lock or Sch-M lock is held in the final phase of the index operation, be careful when you run an online index operation inside an explicit user transaction, such as BEGIN TRANSACTION...COMMIT block. Doing this causes the lock to be held until the end of the transaction, therefore impeding user concurrency.

Online index rebuilding may increase fragmentation when it is allowed to run with MAX DOP > 1 and ALLOW_PAGE_LOCKS = OFF options. For more information, see How It Works: Online Index Rebuild - Can Cause Increased Fragmentation.

Transaction Log Considerations 

Large-scale index operations, performed offline or online, can generate large data loads that can cause the transaction log to quickly fill. To make sure that the index operation can be rolled back, the transaction log cannot be truncated until the index operation has been completed; however, the log can be backed up during the index operation. Therefore, the transaction log must have sufficient space to store both the index operation transactions and any concurrent user transactions for the duration of the index operation. For more information, see Transaction Log Disk Space for Index Operations.

参考文档:

https://msdn.microsoft.com/en-us/library/ms190981(v=sql.110).aspx

时间: 2024-08-06 18:55:50

[转]Guidelines for Online Index Operations的相关文章

学习 Hash Index

一,Hash Index的结构 Hash Index 由buckets集合构成,Index Key 经过 Hash 函数的映射,产生Hash Value,填充到相应的bucket中,每个bucket的Hash Value不同.SQL Server 提供一个hash 函数,用于将 index key 隐射到相应的bucket中.该hash函数是确定性的,对于相同的index key,Hash函数产生hash value是固定的,隐射到相同的bucket上. A hash index consist

Maintenance Plan Usage3:Task Usage (Maintain Index)

Maintenance Plan用于维护Index Fragmentation 和 Statistics的Task 共有三个,后台是使用相应的TSQL来进行data维护. Reorganize Index Task Move index pages into a more efficient search order. This task uses the ALTER INDEX REORGANIZE statement with SQL Server 2012 databases. Rebui

Index Reorganize 和 Rebuild 的区别

对Index 进行 Reorganize 和 Rebuild 是有区别的. 1,语义区别 Rebuild 是重新创建,将Index之前占用的空间释放,重新申请空间来创建index.Rebuilding an index means that a whole new set of pages is allocated for it. Reorganize 是重新组织,作用于 index leaf level pages.Reorganizing an index compacts the leaf

QUOTED_IDENTIFIER 选项对 index的影响

SET QUOTED_IDENTIFIER 选项对Index的影响 当创建或修改的index包含computed columns ,必须 SET QUOTED_IDENTIFIER=ON: 当创建或修改Indexed View上的Index时,必须 SET QUOTED_IDENTIFIER=ON: 当创建或修改filtered index时,必须 SET QUOTED_IDENTIFIER=ON: 一,Case 早上,发现用于处理Index fragmentation的Job跑失败了,查看jo

sql server中index的REBUILD和REORGANIZE

参考文献: http://technet.microsoft.com/en-us/library/ms188388.aspx 使用alter index来rebuild和reorganize索引来清除碎片,rebuild能够完全清除碎片,但是reorganize却不能. --1.准备实验数据 select * into Employee from AdventureWorks2008R2.HumanResources.Employee; --2.查看使用空间:Employee 290 72 KB

SQL错误码

///////////////////////////////////////////////////////////////ORA-00001: 违反唯一约束条件 (.)ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-00020: 超出最大进程数 ()ORA-00021: 会话附属于其它某些进程:无法转换会话ORA-00022: 无效的会话 ID:访问被拒绝ORA-00023: 会话引用进程私用内存:无法分离会话O

04 - 模板方法模式

模版模式: 又叫模板方法模式,在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类可以在不改变算法结构的情冴下,重新定义算法中的某些步骤. 模式中的角色: 抽象类(AbstractClass):实现了模板方法,定义了算法的骨架. 具体类(ConcreteClass):实现抽象类中的抽象方法,已完成完整的算法. 模式优缺点:优点 模板方法模式通过把不变的行为搬移到超类,去除了子类中的重复代码. 子类实现算法的某些细节,有助于算法的扩展. 通过一个父类调用子类实现的操作,通过子

宏btr_pcur_open_on_user_rec

参考http://wqtn22.iteye.com/blog/1820436 http://blog.jcole.us/2013/01/10/btree-index-structures-in-innodb/ #define btr_pcur_open_on_user_rec(i,t,md,l,c,m) \ btr_pcur_open_on_user_rec_func(i,t,md,l,c,__FILE__,__LINE__,m) /*******************************

Identifying a distributed denial of service (DDOS) attack within a network and defending against such an attack

The invention provides methods, apparatus and systems for detecting distributed denial of service (DDoS) attacks within the Internet by sampling packets at a point or points in Internet backbone connections to determine a packet metric parameter. The