dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Glossary/Ghost Record
Ghost RecordMaintenance & Bloat

Ghost Record (Hayalet Kayıt)

Deleted rows marked as ghost records on B-tree index pages rather than physically removed, awaiting asynchronous eviction by the Ghost Cleanup Task.

Internal Architecture Breakdown

To maximize transaction throughput and prevent lock escalations during DELETE operations, SQL Server marks tuples as ghosts rather than deallocating page slots immediately.

The background Ghost Cleanup Task sweeps pages every 10 seconds. However, heavy delete batches or long-running transactions stall cleanup, inflating page counts, degrading index scan speed, and causing index bloat.

Production Inspection Queries

SQL Server
SELECT ghost_record_count, record_count, version_ghost_record_count FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') WHERE ghost_record_count > 0;