From: jitokim (@jitokim) <noreply+jitokim@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #1025: HNSW: insertPage rewinds to unfittable deleted slots after VACUUM, causing near-full index scan per insert with variable-size types (sparsevec) — reproduction for #975
Date: Fri, 25 Sep 2026 00:42:53 +0000
Message-ID: <gh-pgvector-pgvector-1025-c5824713081@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-1025@github.com>
References: <gh-pgvector-pgvector-1025@github.com>
Benchmark numbers from #1026, for reference when trying the FSM approach.
PG 16.15, `sparsevec(10000)`, rows nnz=200, large inserts nnz=1000. All variants start from the same snapshot (build → DELETE → VACUUM). Single runs, ± a few hundred buffers of noise.
- **latch-if-fits**: original #1026
- **tries-bounded**: diff from the #1026 review
- **bounded scan**: current #1026 (jump to last page after 3 unfit pages, insertPage unchanged)
**Repeat large insert after 5% delete + VACUUM (buffers)**
| rows | master | latch-if-fits | tries-bounded | bounded scan |
|---|---|---|---|---|
| 30k | 9,959 | 2,834 | 9,945 | 2,470 |
| 100k | 28,638 | 2,831 | 27,816 | 2,841 |
| 200k | 52,933 | 2,934 | 52,919 | 2,944 |
**Index growth on reinsert after VACUUM (50k rows)**
| | master | latch-if-fits | tries-bounded | bounded scan |
|---|---|---|---|---|
| 10% delete, 5 large then 5,000 small | +10 | +1,259 | +10 | +10 |
| 10% delete, 1 large per 50 small | +200 | +1,400 | +260 | +200 |
| 1% delete, 5 large then 500 small | +10 | +134 | +10 | +10 |
`vector(512)` and same-size `sparsevec` reinserts are identical across all four. `049` (repeat large insert reads < half the index) fails on master and tries-bounded, and should work as a check for an FSM version too.
Looking forward to the FSM approach.