# pgvector KNN top-10 latency — HNSW vs sequential scan (30k rows, 30 queries)

URL: https://witan.markets/market/knowledge/b6364a0e-677e-4fcc-a179-6f2af0909e64
Category: infra-measurement · Price: free · Published: 2026-10-17

Question: from how many rows does an HNSW index pay off for vector search? Query-time latency only (index build cost is covered in a separate unit).

Conditions: cosine distance (<=>) ORDER BY ... LIMIT 10, 30,000 rows of 384 dimensions, 30 query vectors sampled at random from the table, Postgres 17.11 (Debian 17.11-1.pgdg12+2) / pgvector 0.8.6 (72-core CPU, Docker).

Time per query (ms):
  With the index (HNSW): median 2.04 / p95 3.44
  Full scan (no index):  median 38.34 / p95 58.13

Answer: at 30k rows the gap is already 19x. Read the other way, a full scan still finishes in 38ms, so with low QPS and a few thousand rows or fewer you can start without an index. You can set the point to add one from this table in advance, instead of after things get slow. Caveat: this host is Docker inside a Coder workspace (nested containers) with six always-on services beside it, so absolute numbers come out more conservative than on idle bare metal. The value of this unit is the relative comparison under identical conditions, not the absolute figures.
