Skip to content

pg_proven

Nearest-neighbour and vector-set indexing for pgvector types

pg_proven · Nearest-neighbour and vector-set indexing for pgvector types

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102478pg_provenpg_proven0.1.0RAGMITRust

PostgreSQL · 17, 18

Relationships
Requiresvector

Usage

Sources:

pg_proven 0.1.0 provides the proven index access method for vector and vector[] values. The reviewed source targets PostgreSQL 17/18 with pgvector. Its control file and pgrx SQL declarations define a superuser-only, nonrelocatable extension; shared preload is not required.

Nearest Neighbours

CREATE EXTENSION vector;
CREATE EXTENSION pg_proven;
CREATE TABLE items (id bigint, embedding vector(3), tenant_id integer);
INSERT INTO items VALUES (1, '[1,0,0]', 7), (2, '[0,1,0]', 8);
CREATE INDEX items_proven ON items USING proven (embedding vector_cosine_ops, tenant_id);
SELECT id FROM items WHERE tenant_id = 7
ORDER BY embedding <=> '[1,0,0]'::vector LIMIT 10;

The default proven.probes = 0 and proven.recall = 1 scan all lists with executor distance rechecks. L2 uses vector_l2_ops and <->; cosine uses vector_cosine_ops and <=>. NULL vectors and cosine zero vectors are not indexed; a large LIMIT can therefore return fewer rows than a sequential scan, and equal-distance ties need not have the same order. Extra indexed int4 or int8 columns support filtering; other filters run after the index scan.

Approximation and Vector Sets

SET proven.recall = 0.95;
SELECT * FROM proven_recall('items_proven'::regclass);
RESET proven.recall;

A recall value below one selects lists using measurements on the index’s own rows; it is not a recall guarantee for new queries or later inserts. A positive proven.probes takes precedence. proven.k overrides the initial result budget. Vector-array operator classes vector_set_l2_ops and vector_set_cosine_ops support nearest-member ordering and ==> predicates built with vquery_l2 or vquery; boolean names describe whether members lie within the supplied radius. Inner product, halfvec and sparsevec are not supported.

Storage and Maintenance

Index pages use WAL and participate in replication and backup. Searches use a derived mmap cache in $PGDATA/pg_proven/, which can be rebuilt from those pages and roughly doubles disk storage. VACUUM removes dead rows and folds insert deltas; proven_fold requests a fold explicitly. Inserts that cross the folding threshold can wait for that work. Use REINDEX after material data drift or to rebuild an index initially created on an empty table.

SELECT proven_fold('items_proven'::regclass);

Build working memory is not bounded by maintenance_work_mem. Verify plans and compare results against sequential scans before relying on this early implementation. Returned ctid values are unsuitable as stable identifiers, including the documented reorder-queue limitation.

Table reader