liveBook · Manning

Autoshrink

As explained in 100 SQL Server Mistakes and How to Avoid Them

Autoshrink is a SQL Server database option that automatically reduces database files when they contain reclaimable unused space.

Autoshrink automatically reclaims unused database-file space through a periodic SQL Server background task. It seems attractive when storage is expensive or nearly full, but repeatedly shrinking files can cause severe performance problems. section 9.1 section 9.12

Mistake: enabling autoshrink at the storage warning

MagicChoc runs SQL Server in Azure with data-volume utilization near 75 percent. An inexperienced DBA enables autoshrink across four databases. Within an hour, application teams report sharply worse performance as SQL Server repeatedly performs shrink operations. Shrinking also leaves indexes nearly 100 percent fragmented, creating an ongoing loop of poor performance and increased resource use. section 9.1 section 9.12

Use these safer rules:

  • Disable autoshrink rather than treating it as capacity management; investigate growth and plan storage deliberately. section 9.12
  • If a manual shrink is unavoidable, rebuild all indexes afterward and expect operational impact. section 9.12

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains the periodic background task, demonstrates its performance consequences, and stops short of detailed shrink internals.
Examples
Uses a named Azure scenario, four databases, a 75-percent volume warning, diagnostic SQL, and a disabling command.
What it assumes
Assumes basic SQL Server database administration and database-file concepts, while teaching the autoshrink option from its practical motivation.
What you can do after
Operate/configure it by checking database settings, disabling autoshrink, and recognizing when manual shrinking requires index rebuilding.
How it connects
Connects autoshrink to database shrinking, index fragmentation, autogrow, and capacity planning.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.