<!-- llms-explorer concept facts · https://llms-explorer.com/tree/index-prefix-compression-and-index-size/ · pack 2026-10-22 · ~1026 tokens -->

# Index prefix compression and index size

> Source-anchored research for Index prefix compression and index size. Run status: COMPLETED.

Parent: [MongoDB Compound Index Design: ESR, Selectivity, Covering and Multikey Bounds](https://llms-explorer.com/tree/mongodb-compound-index-design-esr-selectivity-covering-and-multikey-bounds/) · 3 facets · 10 facts · page: https://llms-explorer.com/tree/index-prefix-compression-and-index-size/

## How it works

- Prefix compression trades space for CPU and memory work. WiredTiger warns that reconstructing keys has overhead and that compression may not pay when it saves only a few bytes per key or when block compression already addresses the main disk cost. (high confidence) — [source](https://source.wiredtiger.com/11.0.0/tune_page_size_and_comp.html)
- Prefix-compression savings depend on key similarity: Percona identifies repetitive indexes as especially likely to benefit, and a B-tree evaluation found stronger prefix-compression savings when neighboring sorted keys were more similar in its tested distributions. (high confidence) — [source](https://www.percona.com/blog/mongodb-revs-you-up-what-storage-engine-is-right-for-you-part-2/)

## Comparisons and alternatives

- Inference from the adjacent-key encoding: compound-index field order can change which neighboring keys share prefixes. Measure the resulting index sizes with representative values and key patterns instead of assuming a fixed compression percentage. (medium confidence) — [source](https://link.springer.com/article/10.1007/s00778-025-00950-8)

## Facts and statements

- MongoDB's current WiredTiger documentation and the MongoDB 9.0.4 configuration declare `storage.wiredTiger.indexConfig.prefixCompression` enabled by default for indexes (`default: true`); the setting can be disabled. (high confidence) (verified as of 2026-10-20) — [source](https://www.mongodb.com/docs/manual/core/wiredtiger.md)
- WiredTiger's row-store B-tree prefix compression stores a common leading key prefix once per page; later keys retain their suffix and prefix-length metadata. WiredTiger documents that this reduces key representation size both in memory and on disk. (high confidence) — [source](https://source.wiredtiger.com/11.0.0/tune_page_size_and_comp.html)
- MongoDB's WiredTiger documentation says index prefix compression can reduce internal-cache RAM as well as on-disk size; Percona describes the cache benefit as strongest for repetitive indexes. Prefix compression is separate from collection block compression. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/wiredtiger.md)
- MongoDB's `db.collection.totalIndexSize()` and per-index `indexSizes` report compressed size for indexes that use prefix compression, so these metrics are not raw totals of uncompressed key bytes. (high confidence) (verified as of 2026-10-22) — [source](https://www.mongodb.com/docs/manual/faq/storage.md)
- A 2025 B-tree study implemented WiredTiger from its source code and reported lower insertion and point-search performance than an uncompressed B-tree in its in-memory test; it attributed the gap to decompression-like work. This result is a scoped implementation benchmark, not an end-to-end MongoDB workload measurement. (medium confidence) — [source](https://link.springer.com/article/10.1007/s00778-025-00950-8)
- MongoDB documents prefix compression as enabled by default for all WiredTiger indexes and provides the storage.wiredTiger.indexConfig.prefixCompression setting to disable it. (high confidence) (verified as of 2026-10-22) — [source](https://www.mongodb.com/docs/manual/core/wiredtiger.md)
- A smaller prefix-compressed index does not guarantee faster queries. WiredTiger warns that random lookups and reverse cursor movement may reconstruct uncompressed keys at additional CPU and memory cost; in a paper's random-dataset memory experiment, WiredTiger compressed well but had lower throughput than Head+Tail compression, which avoided query-time decompression. (high confidence) — [source](https://source.wiredtiger.com/11.0.0/tune_page_size_and_comp.html)
