# pgvector Documentation

> Open-source vector similarity search for PostgreSQL: vector, halfvec, bit, and sparsevec data types, exact and approximate KNN search, HNSW and IVFFlat indexing.

---

LLMS index: [llms.txt](/llms.txt)

---

**`pgvector`** is the foundational open-source vector similarity search extension for PostgreSQL. It provides the core `vector`, `halfvec`, `bit`, and `sparsevec` data types, distance operators, and built-in **HNSW** and **IVFFlat** index access methods.

> [!TIP] Relationship with `vchord`
> [`vchord`](/docs/vchord/) builds directly on `pgvector`'s data types (`vector` and `halfvec`) and distance operators (`<->`, `<#>`, `<=>`). You can add [`vchord`](/docs/vchord/) (`vchordrq` or `vchordg`) indexes to existing `pgvector` tables without changing your schema or application queries.

## Key Features

- **Exact and approximate nearest-neighbor search** inside standard PostgreSQL tables with full ACID transactions, point-in-time recovery, joins, and filtering.
- **Multiple vector representations**:
  - Single-precision floating-point vectors (`vector`, up to 2,000 dimensions indexed; up to 16,000 dimensions stored)
  - Half-precision floating-point vectors (`halfvec`, up to 4,000 dimensions indexed)
  - Binary vectors (`bit`, up to 64,000 dimensions indexed)
  - Sparse vectors (`sparsevec`, up to 1,000 non-zero elements across up to 1,000,000 dimensions)
- **Six distance metrics**: L2 distance (`<->`), inner product (`<#>`), cosine distance (`<=>`), L1 distance (`<+>`), Hamming distance (`<~>`), and Jaccard distance (`<%>`).
- **Iterative index scans** (`0.8.0+`) that automatically expand HNSW or IVFFlat candidate traversal when `WHERE` filters narrow the result set.

## Documentation Sections


- [Getting Started](/docs/vector/getting-started/) — Install `pgvector` via Pigsty, Docker, Linux packages, Homebrew, or source; enable the extension; and insert or bulk-load vectors.
- [Querying \& Filtering](/docs/vector/querying/) — Distance operators, similarity calculations, vector aggregates, `WHERE` filtering with iterative index scans, and hybrid search.
- [HNSW \& IVFFlat Indexing](/docs/vector/indexing/) — Create and tune HNSW and IVFFlat indexes, parallel index build settings, progress monitoring, and scaling with [`vchord`](/docs/vchord/).
- [Quantization \& Sparse Vectors](/docs/vector/quantization/) — Half-precision (`halfvec`), binary quantization (`bit` + re-ranking), sparse vectors (`sparsevec`), and Matryoshka sub-vector indexing.
- [Reference\, Tuning \& FAQ](/docs/vector/reference/) — Complete SQL function and operator reference, GUC parameters, memory sizing, query plan debugging, and frequently asked questions.
- [Scale with vchord](/docs/vchord/) — Drop-in RaBitQ `vchordrq` and `vchordg` indexes on standard `pgvector` columns for 100M+ vectors without changing queries.

---

Section pages:

- [Getting Started](/docs/vector/getting-started/): Install pgvector on PostgreSQL 14–18 and run your first vector similarity queries.
- [Querying & Filtering](/docs/vector/querying/): Nearest-neighbor operators, distance calculations, aggregates, WHERE filtering with iterative index scans, and hybrid search in pgvector.
- [HNSW & IVFFlat Indexing](/docs/vector/indexing/): Build, tune, and maintain HNSW and IVFFlat approximate nearest-neighbor indexes in pgvector, and compare with vchord.
- [Quantization & Sparse Vectors](/docs/vector/quantization/): Half-precision vectors (halfvec), binary quantization (bit), sparse vectors (sparsevec), and Matryoshka sub-vector indexing in pgvector.
- [Reference, Tuning & FAQ](/docs/vector/reference/): Complete SQL function reference, GUC configuration parameters, performance tuning, monitoring, and FAQ for pgvector.

---

Backlinks:

- [Do we really need a specialized vector database?](/blog/post/do-we-really-need-a-specialized-vector-database/)
- [Do we really need a specialized vector database? (2023)](/blog/post/do-we-really-need-a-specialized-vector-database-2023/)
- [Hybrid search with Postgres Native BM25 and VectorChord](/blog/post/hybrid-search-with-postgres-native-bm25-and-vectorchord/)
- [Vector Search Over PostgreSQL: A Comparative Analysis of Memory and Disk Solutions](/blog/post/vector-search-over-postgresql-a-comparative-analysis-of-memory-and-disk-solutions/)
- [VectorChord: Cost-Efficient Upload & Search of 400 Million Vectors on AWS](/blog/post/vectorchord-cost-efficient-upload-and-search-of-400-million-vectors-on-aws/)
- [Documentation](/docs/)
- [About](/docs/about/)
- [pg_bestmatch](/docs/bestmatch/)
- [Getting Started](/docs/bestmatch/getting-started/)
- [SQL Reference](/docs/bestmatch/reference/)
- [Usage Guide](/docs/bestmatch/usage/)
- [vchord_bm25](/docs/bm25/)
- [Installation](/docs/tokenizer/installation/)
- [vchord](/docs/vchord/)
- [Hybrid Search](/docs/vchord/use-case/hybrid-search/)
