# Heap: A Definition
> [!Note]
> A heap is a table without a clustered index, storing data in no particular order and enabling fast inserts at the cost of slower targeted retrievals.
A **heap** in SQL Server represents a table that does not have a [[Clustered Index]], so its rows are placed on data pages wherever there is free space rather than in a sorted sequence. This unordered storage model means that **INSERT** operations can occur with minimal page splits or page reorganizations, since the engine simply finds the next available slot. However, when you need to retrieve specific rows, the absence of a logical order forces the optimizer to perform a **table scan** or to rely on **nonclustered indexes**, which then require an additional lookup to the heap via row locators.
Over time, heaps are prone to **fragmentation** as deleted or updated rows leave gaps in data pages. This kind of fragmentation can degrade the performance of full scans and index maintenance operations. To address this, you can periodically **rebuild** nonclustered indexes, use the **REBUILD HEAP** operation in newer SQL Server versions, or apply **data compression** techniques to compact the storage and reduce I/O overhead.
> [!Tip]
> When your workload involves large, sequential bulk loads and few selective queries, a heap table can outperform indexed tables by eliminating the overhead of maintaining a clustered index.
---
## References
- Microsoft Docs: _Clustered Index Architecture and Design Guidelines_
- Garcia-Molina, H., Ullman, J. D., & Widom, J. _Database Systems: The Complete Book_
- Korotkevitch, D. (2022). _SQL Server advanced troubleshooting and performance tuning: Best practices and techniques_. O’Reilly Media.
- Nevarez, B. (2022). _SQL Server query tuning and optimization: Optimize Microsoft SQL Server 2022 queries and applications_. Packt Publishing.