pgvector
In-depth entryby Andrew Kane (pgvector project) · Extension
PostgreSQL extension adding vector types, distance operators and HNSW/IVFFlat indexes for similarity search inside the database
Overview
pgvector is an open-source PostgreSQL extension, written in C and maintained by Andrew Kane, that adds vector data types and similarity search to a standard PostgreSQL server. It is distributed under the PostgreSQL License and is preinstalled or installable on most managed PostgreSQL services, which has made it the usual way to add embedding search to an application that already stores its data in Postgres.
The extension defines column types for dense single-precision and half-precision vectors, binary vectors and sparse vectors, together with distance operators for Euclidean, inner-product, cosine, taxicab, Hamming and Jaccard distance. Queries use ordinary SQL: an ORDER BY on a distance expression with a LIMIT returns the nearest neighbors, and WHERE clauses filter on any other column in the same statement. Without an index results are exact; adding an HNSW or IVFFlat index trades some recall for speed on large tables, with tuning parameters exposed as index options and session settings.
Typical use is retrieval-augmented generation: embeddings produced by a model API are written next to the source text, and the application joins vector similarity with metadata filters, full-text search or access-control predicates in one query, then hands the rows to an LLM. Client support comes for free from existing PostgreSQL drivers, and helper packages exist for Python, Node, Ruby, Go and others.
The limits follow from living inside Postgres: index builds and memory use grow with table size, the indexed dimension count is capped per type, and very large or latency-critical collections may be better served by a dedicated vector engine or by partitioning. Recall under heavy filtering depends on index parameters and PostgreSQL version.
Capabilities
- vector, halfvec, bit and sparsevec column types
- L2, inner product, cosine, L1, Hamming and Jaccard distance operators
- Exact search via ORDER BY plus approximate HNSW and IVFFlat indexes
- Combine similarity with SQL filters, joins and full-text search
- Works with any PostgreSQL driver; helper libraries for many languages
- Available on major managed PostgreSQL services
Typical workflows
- Store document embeddings next to source rows for RAG
- Semantic search over product or listing catalogs with metadata filters
- Deduplicate records by embedding similarity inside existing SQL pipelines
Strengths
- No separate vector database to operate
- Transactions and backups shared with the rest of the data
- Permissive license and wide hosting availability
Limitations
- Indexed dimension limits per vector type
- Index build time and memory grow with collection size
- Filtering plus approximate index can reduce recall without tuning
- Single-node scaling tied to the PostgreSQL instance
Prerequisites
- A PostgreSQL server where the extension can be installed or enabled
Who it is for
- Developers adding semantic search to Postgres-backed apps
- Teams building RAG pipelines
Alternatives & comparison
Qdrant, Weaviate, Milvus and Chroma are standalone vector engines with their own storage, APIs and scaling models; pgvector instead extends an existing PostgreSQL database and uses plain SQL. Pinecone is a proprietary managed service with no self-hosted option. Elasticsearch and OpenSearch add vector fields to a full-text search engine. The usual trade-off is operational simplicity and transactional consistency with pgvector against specialized indexing features and horizontal scaling in dedicated systems.
- Chroma
Open-source embedding database with a minimal Python and JavaScript API, usable in-process, as a server or through Chroma Cloud
Open sourceOpen source - Elasticsearch
Distributed search and analytics engine on Apache Lucene with full-text, aggregations, vector search and ES|QL; triple-licensed AGPL, SSPL and Elastic License
MixedOpen source - Milvus
Open-source vector database from Zilliz with Lite, Standalone and Distributed deployments, many index types and GPU acceleration
Open sourceOpen source - Pinecone
Fully managed, proprietary vector database service with serverless indexes, namespaces, metadata filtering and integrated embedding and reranking
ProprietaryFreemium - Qdrant
Open-source vector search engine written in Rust with filterable HNSW indexes, sparse and multi-vector support, REST/gRPC APIs and a managed cloud
Open sourceOpen source - Weaviate
Open-source vector database in Go with pluggable vectorizer modules, hybrid BM25 and vector search, multi-tenancy and a managed cloud
MixedOpen source
Sources & verification
Primary sources consulted for this record. Claims are tied to the fields each source supports; the automated link checker re-verifies every URL on a schedule.
- Licensepgvector LICENSE (PostgreSQL License)checked Nov 1, 2026
https://github.com/pgvector/pgvector/blob/master/LICENSE
Supports: license_spdx, source_model
- Repositorypgvector repositorychecked Nov 1, 2026
https://github.com/pgvector/pgvector
Supports: name, summary, capabilities, languages
Project README is the primary documentation
- Confidence
- High
- Reviewed
- Nov 1, 2026
- Links
- Verified · Nov 2, 2026
Spotted an error?
More in Vector databases
Meilisearch
Meili SAS · Vector databases
Rust search engine for application search-as-you-type with typo tolerance, faceting and hybrid semantic search; MIT core plus BSL enterprise parts
OpenSearch
OpenSearch Software Foundation (Linux Foundation) · Vector databases
Apache-2.0 search and analytics suite forked from Elasticsearch and Kibana, governed by the OpenSearch Software Foundation
Typesense
Typesense, Inc. · Vector databases
GPL-licensed in-memory search engine in C++ offering typo-tolerant instant search, faceting, vector and hybrid search, with Typesense Cloud hosting