pg_turboquant
pg_turboquant · Compact TurboQuant approximate-nearest-neighbor index access method for pgvector vector and halfvec data.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101223 | pg_turboquant | pg_turboquant | 0.1.0 | RAG | MIT | C |
PostgreSQL · 16, 17
Usage
Sources:
pg_turboquant adds the turboquant approximate-nearest-neighbor index access method for pgvector vector and halfvec columns. Its compact fast path targets normalized cosine or inner-product retrieval, with exact reranking performed explicitly in SQL.
Core Workflow
Set lists = 0 for a flat approximate scan or a positive value for IVF routing. The documented production fast lane uses bits = 4, transform = 'hadamard', normalized vectors, and automatic lanes; benchmark recall, latency, index size, build time, WAL, and concurrent writes on representative embeddings before choosing values.
SQL and Observability Surface
tq_approx_candidates(...)returns approximate candidates andtq_rerank_candidates(...)applies the documented SQL-side exact rerank workflow.tq_recommended_query_knobs(...)provides query-setting guidance.tq_index_metadata(...),tq_index_heap_stats(...), andtq_last_scan_stats()expose index, heap, and most-recent-backend-scan diagnostics.tq_maintain_index(...)performs the extension’s lightweight delta-tier merge or compaction work.
Compatibility and Maintenance
The reviewed contract targets PostgreSQL 16 and 17 and pgvector 0.8.1. L2 and non-normalized scans use decoded-vector compatibility scoring, not the faithful quantized fast path. The current format is v2; older indexes require REINDEX or recreation. Exact reranking remains outside the access method, MVCC visibility remains with PostgreSQL’s executor, and the implementation uses generic WAL. Pin versions and validate upgrades, crash recovery, replicas, index-only scans, metadata filters, and maintenance recommendations before production use.