SQL Server Check

Auto close

This is one of many SQL Server checks performed by our free sp_Check tools.

Learn More About Our sp_check Tools

Checks Performed

ID
Check
704
database auto close enabled

What’s the issue?

AUTO_CLOSE is a database option that, when enabled, causes SQL Server to shut down a database and release its resources after the last user disconnects. The next time a connection request arrives, SQL Server must reopen the database and restart it before the request can be serviced. The setting is off by default for most editions but is on by default for SQL Server Express, which is a common reason it appears in production environments.

Why is this a problem?

Every time the database closes and reopens, SQL Server must allocate memory, perform recovery, and rebuild cached execution plans and metadata, which introduces noticeable latency for the first connection after an idle period. For applications that connect intermittently, this produces unpredictable response times and can cause connection timeouts. Auto close also clears the plan cache for that database on every close, eliminating the performance benefits of plan reuse.

In environments with many databases configured this way, the constant open and close cycles generate unnecessary overhead and can flood the error log with database startup messages.

What should you do about this?

Identify affected databases by querying sys.databases where is_auto_close_on = 1. Disable the setting with ALTER DATABASE [DatabaseName] SET AUTO_CLOSE OFF; on each one. Review any databases migrated from SQL Server Express, as these are the most common source of the setting.

Read more…

Type

Performance

Importance

Medium

sp_Checks