简体   繁体   English

由于SQL Server中的事务日志已满,无法删除索引

[英]Can't delete index due to transaction log full in SQL Server

When I try to delete the index with the following command: 当我尝试使用以下命令删除索引时:

DROP INDEX [ClusteredColumnStoreIndex-20180619-104559] ON [dbo].[Transactions]

I get this error: 我收到此错误:

Msg 9002, Level 17, State 4, Line 4 讯息9002,第17级,州4,第4行
The transaction log for database 'Metrics' is full due to 'ACTIVE_TRANSACTION'. 由于“ ACTIVE_TRANSACTION”,数据库“ Metrics”的事务日志已满。

There disk that the database is on is also out of space at this point. 此时,数据库所在的磁盘也空间不足。

Can someone help me delete this index? 有人可以帮我删除此索引吗?

use below techiniques 使用以下技术

1) Make sure the transaction log has been backed up and truncated before running large-scale index operations online, and that the log has sufficient space to store the projected index and user transactions. 1)在联机运行大规模索引操作之前,请确保已备份并截断了事务日志,并且该日志具有足够的空间来存储预计的索引和用户事务。

2) Consider setting the SORT_IN_TEMPDB option to ON for the index operation. 2)考虑将索引操作的SORT_IN_TEMPDB选项设置为ON。 This separates the index transactions from the concurrent user transactions. 这将索引事务与并发用户事务分开。 The index transactions will be stored in the tempdb transaction log, and the concurrent user transactions will be stored in the transaction log of the user database. 索引事务将存储在tempdb事务日志中,并发用户事务将存储在用户数据库的事务日志中。 This allows for the transaction log of the user database to be truncated during the index operation if it is required. 如果需要,这允许在索引操作期间截断用户数据库的事务日志。 Additionally, if the tempdb log is not on the same disk as the user database log, the two logs are not competing for the same disk space. 此外,如果tempdb日志与用户数据库日志不在同一磁盘上,则这两个日志不会争用同一磁盘空间。

Note 注意

Verify that the tempdb database and transaction log have sufficient disk space to handle the index operation. 验证tempdb数据库和事务日志具有足够的磁盘空间来处理索引操作。 The tempdb transaction log cannot be truncated until the index operation is completed. 在完成索引操作之前,无法截断tempdb事务日志。

3) Use a database recovery model that allows for minimal logging of the index operation. 3)使用数据库恢复模型,该模型允许最小记录索引操作。 This may reduce the size of the log and prevent the log from filling the log space. 这可能会减少日志的大小,并阻止日志填充日志空间。

4) Do not run the online index operation in an explicit transaction. 4)不要在显式事务中运行在线索引操作。 The log will not be truncated until the explicit transaction ends. 在显式事务结束之前,日志不会被截断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM