跳转到主要内容

vchord

Vector database plugin for Postgres, written in Rust

vchord : Vector database plugin for Postgres, written in Rust

Overview

ID Extension Package Version Category License Language
1810 vchord vchord 1.3.0 RAG AGPL-3.0-only Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-r No Yes Yes Yes yes no
PGSTY fork; requires vector and preload; vchordg/halfvec scans can return distances out of order; rerank for strict order.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.3.0 19 18 17 16 15 vchord vector
RPM PIGSTY 1.3.0 19 18 17 16 15 vchord_$v pgvector_$v
DEB PIGSTY 1.3.0 19 18 17 16 15 postgresql-$v-vchord postgresql-$v-pgvector
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el8.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el9.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el9.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el10.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el10.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d12.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d12.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d13.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d13.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u22.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u22.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u24.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u24.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u26.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u26.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
Package Version OS ORG SIZE File URL
vchord_18 1.3.0 el8.x86_64 pigsty 3.4 MiB vchord_18-1.3.0-1PGSTY.el8.x86_64.rpm
vchord_18 1.3.0 el8.aarch64 pigsty 3.0 MiB vchord_18-1.3.0-1PGSTY.el8.aarch64.rpm
vchord_18 1.3.0 el9.x86_64 pigsty 3.4 MiB vchord_18-1.3.0-1PGSTY.el9.x86_64.rpm
vchord_18 1.3.0 el9.aarch64 pigsty 3.2 MiB vchord_18-1.3.0-1PGSTY.el9.aarch64.rpm
vchord_18 1.3.0 el10.x86_64 pigsty 3.4 MiB vchord_18-1.3.0-1PGSTY.el10.x86_64.rpm
vchord_18 1.3.0 el10.aarch64 pigsty 3.2 MiB vchord_18-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-18-vchord 1.3.0 d12.x86_64 pigsty 2.9 MiB postgresql-18-vchord_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-18-vchord 1.3.0 d12.aarch64 pigsty 2.5 MiB postgresql-18-vchord_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-18-vchord 1.3.0 d13.x86_64 pigsty 2.9 MiB postgresql-18-vchord_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-18-vchord 1.3.0 d13.aarch64 pigsty 2.5 MiB postgresql-18-vchord_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-18-vchord 1.3.0 u22.x86_64 pigsty 3.2 MiB postgresql-18-vchord_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-18-vchord 1.3.0 u22.aarch64 pigsty 3.0 MiB postgresql-18-vchord_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-18-vchord 1.3.0 u24.x86_64 pigsty 3.2 MiB postgresql-18-vchord_1.3.0-1PGSTY~noble_amd64.deb
postgresql-18-vchord 1.3.0 u24.aarch64 pigsty 3.0 MiB postgresql-18-vchord_1.3.0-1PGSTY~noble_arm64.deb
postgresql-18-vchord 1.3.0 u26.x86_64 pigsty 3.1 MiB postgresql-18-vchord_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-18-vchord 1.3.0 u26.aarch64 pigsty 2.9 MiB postgresql-18-vchord_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
vchord_17 1.3.0 el8.x86_64 pigsty 3.4 MiB vchord_17-1.3.0-1PGSTY.el8.x86_64.rpm
vchord_17 1.3.0 el8.aarch64 pigsty 3.0 MiB vchord_17-1.3.0-1PGSTY.el8.aarch64.rpm
vchord_17 1.3.0 el9.x86_64 pigsty 3.4 MiB vchord_17-1.3.0-1PGSTY.el9.x86_64.rpm
vchord_17 1.3.0 el9.aarch64 pigsty 3.2 MiB vchord_17-1.3.0-1PGSTY.el9.aarch64.rpm
vchord_17 1.3.0 el10.x86_64 pigsty 3.4 MiB vchord_17-1.3.0-1PGSTY.el10.x86_64.rpm
vchord_17 1.3.0 el10.aarch64 pigsty 3.2 MiB vchord_17-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-17-vchord 1.3.0 d12.x86_64 pigsty 2.9 MiB postgresql-17-vchord_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-17-vchord 1.3.0 d12.aarch64 pigsty 2.5 MiB postgresql-17-vchord_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-17-vchord 1.3.0 d13.x86_64 pigsty 2.9 MiB postgresql-17-vchord_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-17-vchord 1.3.0 d13.aarch64 pigsty 2.5 MiB postgresql-17-vchord_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-17-vchord 1.3.0 u22.x86_64 pigsty 3.2 MiB postgresql-17-vchord_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-17-vchord 1.3.0 u22.aarch64 pigsty 3.0 MiB postgresql-17-vchord_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-17-vchord 1.3.0 u24.x86_64 pigsty 3.2 MiB postgresql-17-vchord_1.3.0-1PGSTY~noble_amd64.deb
postgresql-17-vchord 1.3.0 u24.aarch64 pigsty 3.0 MiB postgresql-17-vchord_1.3.0-1PGSTY~noble_arm64.deb
postgresql-17-vchord 1.3.0 u26.x86_64 pigsty 3.1 MiB postgresql-17-vchord_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-17-vchord 1.3.0 u26.aarch64 pigsty 2.9 MiB postgresql-17-vchord_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
vchord_16 1.3.0 el8.x86_64 pigsty 3.3 MiB vchord_16-1.3.0-1PGSTY.el8.x86_64.rpm
vchord_16 1.3.0 el8.aarch64 pigsty 2.9 MiB vchord_16-1.3.0-1PGSTY.el8.aarch64.rpm
vchord_16 1.3.0 el9.x86_64 pigsty 3.4 MiB vchord_16-1.3.0-1PGSTY.el9.x86_64.rpm
vchord_16 1.3.0 el9.aarch64 pigsty 3.1 MiB vchord_16-1.3.0-1PGSTY.el9.aarch64.rpm
vchord_16 1.3.0 el10.x86_64 pigsty 3.4 MiB vchord_16-1.3.0-1PGSTY.el10.x86_64.rpm
vchord_16 1.3.0 el10.aarch64 pigsty 3.1 MiB vchord_16-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-16-vchord 1.3.0 d12.x86_64 pigsty 2.9 MiB postgresql-16-vchord_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-16-vchord 1.3.0 d12.aarch64 pigsty 2.5 MiB postgresql-16-vchord_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-16-vchord 1.3.0 d13.x86_64 pigsty 2.9 MiB postgresql-16-vchord_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-16-vchord 1.3.0 d13.aarch64 pigsty 2.5 MiB postgresql-16-vchord_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-16-vchord 1.3.0 u22.x86_64 pigsty 3.1 MiB postgresql-16-vchord_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-16-vchord 1.3.0 u22.aarch64 pigsty 2.9 MiB postgresql-16-vchord_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-16-vchord 1.3.0 u24.x86_64 pigsty 3.1 MiB postgresql-16-vchord_1.3.0-1PGSTY~noble_amd64.deb
postgresql-16-vchord 1.3.0 u24.aarch64 pigsty 2.9 MiB postgresql-16-vchord_1.3.0-1PGSTY~noble_arm64.deb
postgresql-16-vchord 1.3.0 u26.x86_64 pigsty 3.1 MiB postgresql-16-vchord_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-16-vchord 1.3.0 u26.aarch64 pigsty 2.9 MiB postgresql-16-vchord_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
vchord_15 1.3.0 el8.x86_64 pigsty 3.3 MiB vchord_15-1.3.0-1PGSTY.el8.x86_64.rpm
vchord_15 1.3.0 el8.aarch64 pigsty 2.9 MiB vchord_15-1.3.0-1PGSTY.el8.aarch64.rpm
vchord_15 1.3.0 el9.x86_64 pigsty 3.3 MiB vchord_15-1.3.0-1PGSTY.el9.x86_64.rpm
vchord_15 1.3.0 el9.aarch64 pigsty 3.1 MiB vchord_15-1.3.0-1PGSTY.el9.aarch64.rpm
vchord_15 1.3.0 el10.x86_64 pigsty 3.3 MiB vchord_15-1.3.0-1PGSTY.el10.x86_64.rpm
vchord_15 1.3.0 el10.aarch64 pigsty 3.1 MiB vchord_15-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-15-vchord 1.3.0 d12.x86_64 pigsty 2.9 MiB postgresql-15-vchord_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-15-vchord 1.3.0 d12.aarch64 pigsty 2.5 MiB postgresql-15-vchord_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-15-vchord 1.3.0 d13.x86_64 pigsty 2.9 MiB postgresql-15-vchord_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-15-vchord 1.3.0 d13.aarch64 pigsty 2.5 MiB postgresql-15-vchord_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-15-vchord 1.3.0 u22.x86_64 pigsty 3.1 MiB postgresql-15-vchord_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-15-vchord 1.3.0 u22.aarch64 pigsty 2.9 MiB postgresql-15-vchord_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-15-vchord 1.3.0 u24.x86_64 pigsty 3.1 MiB postgresql-15-vchord_1.3.0-1PGSTY~noble_amd64.deb
postgresql-15-vchord 1.3.0 u24.aarch64 pigsty 2.9 MiB postgresql-15-vchord_1.3.0-1PGSTY~noble_arm64.deb
postgresql-15-vchord 1.3.0 u26.x86_64 pigsty 3.1 MiB postgresql-15-vchord_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-15-vchord 1.3.0 u26.aarch64 pigsty 2.9 MiB postgresql-15-vchord_1.3.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg vchord;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install vchord;		# install via package name, for the active PG version

pig install vchord -v 18;   # install for PG 18
pig install vchord -v 17;   # install for PG 17
pig install vchord -v 16;   # install for PG 16
pig install vchord -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'vchord';

Create this extension with:

CREATE EXTENSION vchord CASCADE; -- requires vector

Usage

Sources:

vchord 1.2.0 provides approximate vector search on PostgreSQL 14–18. It uses pgvector’s types and adds the partitioned vchordrq index and the disk graph vchordg index. It requires the vector extension, shared preloading, and superuser privileges to install. Graph indexing is documented as a preview feature.

Add the library to the existing preload list and restart PostgreSQL:

shared_preload_libraries = 'vchord'
CREATE EXTENSION vchord CASCADE;
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]'), ('[3,1,2]');
CREATE INDEX items_embedding_idx ON items
USING vchordrq (embedding vector_l2_ops);

SELECT id, embedding <-> '[3,1,2]' AS distance
FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;

Small datasets can start with an unpartitioned index. For larger datasets, choose the partition hierarchy through TOML build.internal.lists, then set vchordrq.probes to the number of partitions to search at each level. More probes trade query work for recall; the probe list must match the hierarchy. The graph alternative uses the same column and distance operator classes:

CREATE INDEX items_embedding_graph_idx ON items
USING vchordg (embedding vector_l2_ops)
WITH (options = $$
m = 32
ef_construction = 64
$$, ef_search = 128);

Use the graph definition as an alternative to the partitioned index above. The recall example below assumes only the partitioned index exists; inspect the query plan when comparing index methods.

Types, Operators, and Tuning

Object Purpose
vector_l2_ops, <-> Euclidean distance, ordered ascending.
vector_ip_ops, <#> Negative inner product, ordered ascending.
vector_cosine_ops, <=> Cosine distance, ordered ascending.
halfvec Half-precision vectors, with corresponding halfvec_*_ops classes.
rabitq4, rabitq8 Quantized vector storage; conversion loses precision.
sphere, <<->>, <<#>>, <<=>> Distance-radius predicates for L2, inner product, and cosine search.
vchordrq.epsilon Reranking tradeoff; default 2.5 in 1.2.0, previously 1.9.
vchordg.ef_search Graph search breadth; default 64.
vchordrq_prewarm, vchordg_prewarm Load hot index pages; require table ownership or table-level SELECT.
SELECT id FROM items
WHERE embedding <<->> sphere('[1,2,3]'::vector, 0.5);

SELECT dequantize_to_vector(quantize_to_rabitq8('[1,2,3]'::vector));
SELECT dequantize_to_halfvec(quantize_to_rabitq4('[1,2,3]'::halfvec));

Sphere radii use the distance operator’s units. PostgreSQL rechecks graph sphere predicates, but approximate search can still miss matching rows. Dequantization cannot recover the original vector exactly.

Per-index probes, epsilon, and ef_search options supply search defaults. Explicit GUC settings, including database or server settings, override them. Resetting a session setting restores its configured default, which can still override the index.

Ordering and Recall

Graph scans can discover closer rows after returning earlier candidates; nearly equal half-precision distances can also appear out of order. Increasing the search breadth reduces some ordering errors but does not guarantee strict ordering. Materialize a larger candidate set and sort it explicitly when ordering matters:

WITH candidates AS MATERIALIZED (
    SELECT id, embedding <-> '[3,1,2]' AS distance
    FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 100
)
SELECT * FROM candidates ORDER BY distance LIMIT 10;

This sorts the retrieved candidates; recall still depends on the candidate count and search parameters. For partitioned indexes, compare approximate results with an exact baseline:

SELECT vchordrq_evaluate_query_recall(
    query => $$SELECT ctid FROM items
                ORDER BY embedding <-> '[3,1,2]' LIMIT 5$$,
    exact_search => true
);

The query must return ctid; keep sequential scans enabled for the exact pass. Multi-vector MaxSim queries using @# require exact_search => true for recall evaluation.

Maintenance and Upgrade

Keep normal vacuuming enabled: graph searches exclude deleted vertices after VACUUM, and index maintenance updates tuple/page statistics. ANALYZE alone does not rebuild or compact the index.

Install matching 1.2.0 library and SQL files, restart PostgreSQL to load the new library, then update each database as the extension owner or an administrator:

ALTER EXTENSION vchord UPDATE TO '1.2.0';

The release provides upgrade paths from 0.2.0 through 1.1.1 without reindexing. Recheck representative rankings after upgrading: 1.2.0 fixes MaxSim candidate estimates, graph sphere filters, deleted-vertex visibility, and quantization edge cases, and raises the default reranking budget. The extension is relocatable; include its chosen schema in the search path or qualify its objects.

表格阅读器