pgvector
Open-source vector similarity search for Postgres
Store your vectors with the rest of your data. Supports:
• exact and approximate nearest neighbor search
• single-precision, half-precision, binary, and sparse vectors
• L2 distance, inner product, cosine distance, L1 distance, Hamming distance, and Jaccard distance
• any language with a Postgres client
Plus ACID compliance, point-in-time recovery, JOINs, and all of the other great features of Postgres
Compile and install the extension (supports Postgres 13+)
cd /tmp
git clone --branch v0.8.7 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudo
See the installation notes if you run into issues
You can also install it with Docker, Homebrew, PGXN, APT, Yum, pkg, APK, or conda-forge, and it comes preinstalled with Postgres.app and many hosted providers. There are also instructions for GitHub Actions.
Ensure C++ support in Visual Studio is installed and run x64 Native Tools Command Prompt for VS [version] as administrator. Then use nmake to build:
set "PGROOT=C:\Program Files\PostgreSQL\18"
cd %TEMP%
git clone --branch v0.8.7 https://github.com/pgvector/pgvector.git
cd pgvector
nmake /F Makefile.win
nmake /F Makefile.win install
See the installation notes if you run into issues
You can also install it with Docker or conda-forge.
Enable the extension (do this once in each database where you want to use it)
CREATE EXTENSION vector;
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]');
SELECT * FROM items ORDER BY embedding '[3,1,2]' LIMIT 5;
Also supports inner product (), cosine distance (), and L1 distance (``)
Note: `` returns the negative inner product since Postgres only supports ASC order index scans on operators
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
ALTER TABLE items ADD COLUMN embedding vector(3);
Also supports half-precision, binary, and sparse vectors
INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]');
Or load vectors in bulk using COPY (example)
COPY items (embedding) FROM STDIN WITH (FORMAT BINARY);
INSERT INTO items (id, embedding) VALUES (1, '[1,2,3]'), (2, '[4,5,6]')
ON CONFLICT (id) DO UPDATE SET embedding = EXCLUDED.embedding;
UPDATE items SET embedding = '[1,2,3]' WHERE id = 1;
DELETE FROM items WHERE id = 1;
SELECT * FROM items ORDER BY embedding '[3,1,2]' LIMIT 5;
Supported distance functions are:
• - L2 distance • - (negative) inner product
• - cosine distance • - L1 distance
• - Hamming distance (binary vectors) • - Jaccard distance (binary vectors)
SELECT * FROM items WHERE id != 1 ORDER BY embedding (SELECT embedding FROM items WHERE id = 1) LIMIT 5;
Get rows within a certain distance …
Builder tool · Builder tools / Vector databases · Open Source · PostgreSQL License · C
Website https://github.com/pgvector/pgvector · Repo https://github.com/pgvector/pgvector
23,654 stars · 1,390 forks · 17 open issues · pushed 2026-11-11 · verified 2026-11-12
Tags: ai-agents, tool, vector-databases
What is pgvector? pgvector is a coding website listed on Scriptiii Webnest. Postgres extension for vector similarity search. Pricing: Free. Free to use. Best for: ai-agents, tool, vector-databases.
Everything you need to know about pgvector
Similar websites in Coding
Open-source vector database that stores objects and vectors with hybrid search and filtering.
Coding·Free