# pg_turboquant

A PostgreSQL extension that adds a compact approximate-nearest-neighbor index for pgvector's vector and halfvec types, built around PostgreSQL's own storage and executor.

pg_turboquant adds a custom access method, turboquant, to PostgreSQL for approximate nearest-neighbor search over vector and halfvec columns. Rather than treating ANN search as an external service, it works within PostgreSQL's own storage and executor: MVCC stays in the executor, exact reranking stays in SQL, and the index uses PostgreSQL's write-ahead log.

It combines a structured-transform payload for normalized cosine and inner-product retrieval with structure-of-arrays batch pages that pack 4-bit dimension-major values for zero-copy SIMD scoring, using NEON or AVX2 kernels with accumulation in int16. It supports flat and IVF-routed scans, bitmap filtering for predicate-heavy queries, and SQL-side exact reranking helpers, plus a reproducible benchmark harness with regression gates. L2 and non-normalized scans fall back to decoded-vector scoring rather than the faster quantized path.

It is written in C and distributed under the MIT license.

Website: https://github.com/mayflower/pg_turboquant
