Skip to content
WebsiteHosting.com

concept Data & storage

B-tree page splits and index amplification

One index insert can change two leaves and their parent. Compare a key that fills the last slot with one that forces a B-tree split, and distinguish changed pages from disk writes.

Latest recorded source check · P0139

What it means

One new index key can change more than one B-tree page. A leaf is the page where the new entry belongs. If the entry fits, the index can add it there. If it does not fit, the leaf may split: some entries move to a new sibling page, and the parent needs a link to that sibling. That is extra work to maintain the index, not a count of writes to disk.

Try it

Simulation: Start with Leaf capacity at 4, Existing keys in leaf at 4, and Required scenario evidence set to provided. The simulation adds one distinct key. That makes 5 keys for 4 slots. The result is two leaves holding 2 and 3 keys, with 3 modeled page writes: one for each leaf and one for the parent.

B-tree page splits and index amplification

Explain page fill, splits and read/write amplification of index maintenance

Simulation
Modeled outcome: Split

Full leaf splits, adds a sibling and changes parent pointer/separator.

B-tree page splits and index amplification: synthetic scenario inputs
Replaces all inputs with the documented starting example and the indicated change. Reset restores the starting example.
Leaf occupancy and page writes

Insertion and structural change

  1. Inserted entries1
  2. Leaf pages after2
  3. Parent updateIncluded in split write count
  4. Page writes3
  5. ReadsNot modeled
Leaf before insert4 entries
Leaf 1 after2 entries
Leaf 2 after3 entries

Slots are counts, not actual keys. A split includes a modeled parent update but no computed separator value or read counter. Real engines may perform different work.

Evaluated inputs

Required scenario evidence
provided
Existing keys in leaf
4 count
Leaf capacity
4 count
New distinct keys
1 count

Fixed-size entries, one leaf, parent has room, logical page touches not physical I/O/WAL or actual fill-factor.

About this model

The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.

Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.

Change only Existing keys in leaf from 4 to 3. The new key now occupies the last free slot. The result is one leaf holding 4 keys and 1 modeled page write. The leaf ends up full, but it did not split. What matters is whether the key fits at the time of insertion.

Choose missing for the evidence and neither result follows: the counts are not used to decide whether the key fits. An invalid count, such as a fractional capacity, is a different problem; it needs correction, not rounding. Reset restores the full four-slot leaf, one new key, and provided evidence. The simulation does not inspect or change a database.

Why the parent changes

Before the split, the parent directs searches for this range of keys to one leaf. After the split, the keys still have the same search order, but part of the range is on the sibling. The parent needs a separator marking the boundary and a link directing searches to the new page. Moving entries between leaves accounts for two changed pages; keeping both ranges reachable accounts for the third.

The example assumes fixed-size entries and room in the parent for that link. Its 2-and-3 distribution describes where the five entries end up, not how many pages a search reads. The simulation counts changed pages, not reads.

The capacity bars depict entries on a page; they do not count page reads. The split picture also labels the parent update without inventing the new separator key. To compare observed I/O, you would need separate measurements for the actual operation and workload, not just the structural write count.

In practice

To explain the extra work for an insert, compare the space in the target leaf before the insert with the space the entry needs. With the layout held constant here, one free slot makes the difference between a leaf update and a split with a parent update. The four-slot capacity is an example, not a PostgreSQL fill factor or a threshold to apply to a real index.

If the question is about storage activity, use evidence from that layer. PostgreSQL distinguishes buffer hits and reads from buffers dirtied or written. Its write-ahead log (WAL) also has a write path distinct from the index pages. The modeled count answers “Which pages had to change?” To answer “How much disk I/O did this cost?”, look for measurements from the workload rather than treating three changed pages as three device writes.

Frequently asked questions

Editorial questions based on the listed sources and explicitly labeled local examples.

Can splits cascade?

Yes, if parent capacity is exhausted.

Does fill factor eliminate all splits?

No. Lower B-tree fillfactor leaves room for future entries and can delay some splits, depending on the workload. Inserts can eventually fill the remaining space. This lab uses a small fixed page capacity, not a performance forecast.

Are page touches physical writes?

No. PostgreSQL reports buffer hits, reads, dirtied and written buffers separately, and WAL has its own write path. The lab counts page operations, not a measured number of device writes.

Does a split change key order?

No arbitrary rearrangement follows from a split: the B-tree maintains search order while some entries move to a sibling and the parent gains a downlink. The lab computes occupancy and structural write counts; it does not calculate the actual separator key.

Sources & model boundaries

Primary references used for this explanation. The interactive example is an educational model, not a live check.

  1. PostgreSQL B-tree indexes

    page splits. A split moves tuples to a new page and inserts a parent downlink, which can cascade.

    Checked .

  2. PostgreSQL CREATE INDEX

    Storage parameters: fillfactor. A lower B-tree fillfactor leaves space for future insertions and can smooth some page splits. It is not a guarantee of no split or a forecast of I/O.

    Checked .

  3. PostgreSQL Using EXPLAIN

    14.1.2 EXPLAIN ANALYZE: BUFFERS. PostgreSQL 18 distinguishes buffer hits, reads, dirtied and written buffers. These are counts of buffer activity, not the modeled logical page write count or a direct count of physical device I/O.

    Checked .

  4. PostgreSQL WAL introduction

    §28.3 WAL introduction. WAL records and data-file pages have distinct write paths. WAL supports recovery without requiring every changed data page to reach durable storage at each commit. Buffer counters are documented separately in EXPLAIN; this toy counts page operations, not device writes.

    Checked .

Report an issue. Include the article URL and ID, not passwords or access keys.