# pgvector

> Open-source Postgres extension for storing vectors and running exact and approximate nearest neighbor similarity search.

pgvector is an open-source extension that adds vector storage and similarity search to Postgres, so embeddings can live alongside the rest of an application's data. It supports exact and approximate nearest neighbor search, several vector types and distance functions, and works from any language with a Postgres client. The README documents version 0.8.7 and support for Postgres 13 and later.

## What It Is

pgvector is a Postgres extension enabled per database with `CREATE EXTENSION vector`. It adds column types for vectors: single-precision `vector`, half-precision `halfvec`, binary `bit`, and `sparsevec`. Queries use distance operators for L2, inner product, cosine, L1, Hamming and Jaccard distance. Because it runs inside Postgres, vector queries can use ACID compliance, point-in-time recovery, JOINs and the rest of Postgres.

## Indexing and Search

By default pgvector performs exact nearest neighbor search. Adding an HNSW or IVFFlat index switches to approximate search, trading some recall for speed. The README says HNSW has better speed-recall performance but slower builds and higher memory use, while IVFFlat builds faster and uses less memory. Iterative index scans, added in 0.8.0, scan more of the index when filtered queries return too few results. Hybrid search combines vector queries with Postgres full-text search.

## Scaling and Operations

For larger datasets, the documentation recommends half-precision vectors, binary quantization with re-ranking, and subvector indexing. It covers tuning, bulk loading with COPY, concurrent index builds, and monitoring with pg_stat_statements or PgHero. Horizontal scaling options include replicas and sharding with Citus or PgDog. Multitenant setups can isolate tenants with list partitioning or separate tables.

## Installation Paths

It can be compiled from source on Linux, Mac and Windows. It is also available through Docker, Homebrew, PGXN, APT, Yum, pkg, APK and conda-forge, and comes preinstalled with Postgres.app and many hosted Postgres providers. Client libraries and examples exist for many languages, including Python, JavaScript, Go, Java, Rust and Ruby.

## Features
- Exact and approximate nearest neighbor search
- HNSW and IVFFlat indexes
- Single-precision, half-precision, binary and sparse vectors
- L2, inner product, cosine, L1, Hamming and Jaccard distances
- Iterative index scans for filtered queries
- Binary quantization and subvector indexing
- Hybrid search with Postgres full-text search
- Parallel index builds
- Replication and point-in-time recovery via WAL
- Vector aggregates such as AVG and SUM

## Integrations
PostgreSQL, Docker, Homebrew, PGXN, APT, Yum, conda-forge, Postgres.app, Citus, PgDog, PgHero, pg_stat_statements

## Platforms
WINDOWS, MACOS, LINUX, API, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Version
0.8.7

## Links
- Website: https://github.com/pgvector/pgvector
- Documentation: https://github.com/pgvector/pgvector#readme
- Repository: https://github.com/pgvector/pgvector
- EveryDev.ai: https://www.everydev.ai/tools/pgvector
