pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: R3gardless (@R3gardless) <noreply+R3gardless@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #967: `halfvec` table + index shows unexpected QPS degradation and slower index build vs `vector`/flat in HNSW
Date: Mon, 09 Mar 2026 10:08:57 +0000
Message-ID: <gh-pgvector-pgvector-967@github.com> (raw)

HI! I'm currently researching performance anaysis using [VectorDBBench](https://github.com/zilliztech/VectorDBBench).

**Environment**

- **Dataset** : Cohere-10M (10M vectors, 768 dim, COSINE)
- **CPU** : 48 cores
- **Memory** : 64 GB
- **HNSW params** : m = 16, ef_construction = 64
- **pgvector version** : 0.8.0
- **postgresql version** : 15.13

**Configuration Tested**

  | Config | Table Type | Index Type | Index Size |
  |--------|-----------|------------|------------|
  | vec/flat | `vector` | `vec (no quantization)` | 38 GB |
  | vec/halfvec | `vector` | `halfvec` | 19 GB |
  | halfvec/halfvec | `halfvec` | `halfvec` | 19 GB |

  ### Observation 1: QPS Degradation

  At `maintenance_work_mem=30GB`, both halfvec configurations show consistently lower QPS than vec/flat across all `ef_search` values.

  | ef_search | vec/flat | vec/halfvec | halfvec/halfvec |
  |-----------|---------|-------------|-----------------|
  | 40 | 2,349 | 1,717 (**-27%**) | 1,891 (**-19%**) |
  | 80 | 1,835 | 1,312 (**-29%**) | 1,478 (**-19%**) |
  | 220 | 1,191 | 1,065 (**-11%**) | 1,147 (**-4%**) |

  I can understand that `vec/halfvec` needs extra overhead for float32→float16 type conversion at query time. However, **`halfvec/halfvec` — where no type conversion should be needed — still shows ~19% lower QPS**. This is the part I don't fully understand.

  ### Observation 2: Index Build Time Inversion at Low Memory

  At low `maintenance_work_mem`, the halfvec index build (optimize phase) is significantly **slower** than vec/flat, despite the index being half the size (19 GB vs 38 GB).

  | maintenance_work_mem | vec/flat | vec/halfvec | halfvec/halfvec |
  |---------------------|---------|-------------|-----------------|
  | 512MB | 130 min | 366 min (**2.8x**) | 366 min (**2.8x**) |
  | 1GB | 130 min | 358 min (**2.8x**) | 358 min (**2.8x**) |
  | 10GB | 132 min | 221 min (1.7x) | 220 min (1.7x) |
  | 20GB | 137 min | 83 min | 81 min |
  | 30GB | 110 min | 73 min | 73 min |

  At 20GB+ `maintenance_work_mem`, halfvec builds faster as expected (smaller index fits in memory). But at 512MB–1GB, it's **2.8x slower** — this seems counterintuitive for a half-sized index.

  ### Benchmark Results

<img width="2676" height="1032" alt="Image" src="https://github.com/user-attachments/assets/11d27229-97bd-41ce-b222-2e6a1e27e08d"; />

  ### Questions

  1. Why does `halfvec/halfvec` show ~19% lower QPS than `vec/flat`? Since both table and index use halfvec natively, there should be no type conversion overhead. Is this possibly related to halfvec distance computation being less optimized (e.g. SIMD) compared to
  float32?

  2. Why is the halfvec index build dramatically slower at low `maintenance_work_mem`? The index is half the size — shouldn't it build faster regardless of memory?

  If you need more additional information please let me know.

  Thanks!

view thread (8+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-967@github.com>
Permalink:  ../gh-pgvector-pgvector-967@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox