SQL Server 2019数据库“正常,已自动关闭”

现象:

SQL Server 2019中,某个数据库在SQL Server Management Studio(SSMS)中的状态显示为“正常,已自动关闭”。

解释:

如此显示,是由于该数据库的AUTO_ CLOSE选项被设为True。

在微软的官方文档中,对于这个选项是这样介绍的:

When AUTO_CLOSE is set ON, this option can cause performance degradation on frequently accessed databases because of the increased overhead of opening and closing the database after each connection. AUTO_CLOSE also flushes the procedure cache after each connection.

If a database is accessed frequently, set the AUTO_CLOSE option to OFF for the database.

译文如下:

当AUTO_ CLOSE启用时,由于在每次连接时增加了打开和关闭数据库的开销,该选项可能导致频繁访问的数据库性能降低。在每次连接后,AUTO_ CLOSE也会清理过程缓存。

如果某个数据库经常被访问,则应设置该数据库的AUTO_ CLOSE选项为关闭。

解决方法:

打开该数据库的属性,在左侧选择“选项”。然后在右侧找到“自动”分组,将“自动关闭”设置为False。

参考内容:

Set the AUTO_CLOSE Database Option to OFF - SQL Server | Microsoft LearnCheck whether the AUTO_ CLOSE option is OFF. The AUTO_ CLOSE option has implications for performance in SQL Server.icon-default.png?t=O83Ahttps://learn.microsoft.com/en-us/sql/relational-databases/policy-based-management/set-the-auto-close-database-option-to-off?view=sql-server-ver15

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值