Getting Started
Installation
Pigsty / Native Linux Packages (Recommended)
Pigsty provides prebuilt native pgvector packages (v0.8.2) for PostgreSQL 14–18 across Debian, Ubuntu, and RHEL/Rocky/AlmaLinux (x86_64 and ARM64):
If you also want disk-friendly RaBitQ vector indexes and BM25 ranking, install the full Vchord suite together:
Docker
Run the official pgvector container image:
Or use the all-in-one Vchord Suite image, which bundles pgvector, vchord, vchord_bm25, and pg_tokenizer:
Linux (PGDG APT / YUM)
- Debian / Ubuntu (via PostgreSQL APT Repository):
- RHEL / Rocky / AlmaLinux / Fedora (via PostgreSQL YUM Repository):
macOS (Homebrew)
Build from Source (Linux / macOS)
Ensure PostgreSQL development headers (postgresql-server-dev-* or postgresql*-devel), make, and a C compiler are installed:
To compile with -march=native for maximum SIMD performance on the current machine, pass OPTFLAGS="" only if needed for portability; by default pgvector’s Makefile adds -march=native when supported by the compiler. If building a portable binary for multiple CPU generations, run make OPTFLAGS="".
Enable the Extension
Connect to your target database and enable vector (this must be done once per database where you want to use it):
Check the installed version:
Upgrading pgvector
After installing a newer binary package on the server, upgrade the SQL catalog definitions inside each database:
Quick Start
1. Create a Table with a vector Column
Create a table storing 3-dimensional single-precision (float32) vectors:
You can also add a vector column to an existing table:
2. Insert, Upsert, Update, and Delete Vectors
Insert vectors using the string literal format '[x1,x2,x3]':
Upsert vectors with ON CONFLICT:
Update and delete rows with standard SQL:
3. Bulk Loading with COPY
For large datasets (millions of vectors), always prefer COPY over row-by-row INSERT:
4. Query Nearest Neighbors
Find the 5 closest vectors by L2 (Euclidean) distance:
Next, read Querying & Filtering for all distance metrics and filtering patterns, or HNSW & IVFFlat Indexing to accelerate queries over large tables.