vectors
vectors · Vector database plugin for PostgreSQL, written in Rust, specifically designed for LLM
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100796 | vectors | vectors | 0.4.0 | RAG | Apache-2.0 | Rust |
PostgreSQL · 14, 15, 16, 17
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
- Official version 0.4.0 README
- Official version 0.4.0 extension SQL
- Official migration guide from PGVecto.rs to VectorChord
vectors is the canonical extension name of PGVecto.rs 0.4.0, a Rust/pgrx vector-similarity extension. It supplies dense, half-precision, sparse, and binary vector types plus its own vectors index access method. Upstream now advises users to migrate to VectorChord; choose vectors mainly for maintaining an existing PGVecto.rs deployment.
Setup and Search
The library must be included in shared_preload_libraries and PostgreSQL restarted before creating the extension. Its objects are installed in the vectors schema.
For dense vector, <-> is squared Euclidean distance, <#> is negative dot product, and <=> is cosine distance. Select the matching vector_l2_ops, vector_dot_ops, or vector_cos_ops class for the query operator. Other types include vecf16, svector, and bvector, with corresponding operator classes; binary vectors also support Hamming/Jaccard-oriented operations.
Search GUCs include vectors.hnsw_ef_search, vectors.ivf_nprobe, vectors.search_mode, and quantization rerank/fast-scan settings. Tune recall and latency with representative data rather than treating defaults or published benchmarks as guarantees.
Lifecycle and Migration
PGVecto.rs index storage is managed separately from PostgreSQL heap storage, and the upstream overview warns that index WAL support is incomplete. Exercise crash recovery, replication, backup/restore, upgrades, REINDEX, and extension removal on the exact 0.4.0 build. Index columns require a fixed dimension.
The official VectorChord migration path installs vchord/vector in a different schema, records and drops PGVecto.rs indexes, converts columns through documented casts, and recreates indexes. Type conversion takes an ACCESS EXCLUSIVE lock and therefore causes downtime. svector also needs index-number conversion because PGVecto.rs uses zero-based sparse indexes while pgvector uses one-based indexes. Keep the old extension until every dependent column and index has been migrated and verified.