# pgvector

> Canonical: https://skillalmanac.com/glossary/pgvector | Last verified: 2026-11-24 | Index status: not offered to search engines

pgvector is an open-source extension for the PostgreSQL database that stores vectors (long lists of numbers, such as text embeddings) in ordinary tables and finds the nearest ones to a query vector.

Also called: pg vector, pgvector extension, postgres vector, pgvector postgres, Postgres vector search.

## In plain language

pgvector adds a new kind of column to the Postgres database so that it can hold the lists of numbers (vectors) that AI tools use to represent the meaning of text or images. You can then ask the database for the rows closest to a new vector, and still use normal tables and queries beside it. For a company that already runs Postgres, that can mean one fewer system to look after. It is an add-on to a database, not a complete AI product. Fast approximate search trades some accuracy for speed, and storing many vectors adds memory and storage cost, so test with your own data before relying on it.

## Technical definition

pgvector is a PostgreSQL extension, enabled in a database with CREATE EXTENSION, that adds a vector type and distance operators. Its README lists L2 distance, inner product, cosine distance, L1, Hamming and Jaccard distance. By default queries do exact nearest-neighbour search, which the README says gives perfect recall. Adding an index enables approximate search that trades some recall for speed. The README describes two index types: HNSW, a multilayer graph, and IVFFlat, which divides vectors into lists and searches a subset of them. It also says vectors sit alongside the rest of the data, with Postgres features such as ACID compliance and JOINs.

## How it shows up when you use agents

pgvector appears when a project keeps its AI search inside the Postgres database it already runs. An agent that scaffolds a [retrieval-augmented generation](/glossary/retrieval-augmented-generation) app may write SQL that enables the extension, creates a column for [embeddings](/glossary/embedding) and orders rows by distance to a query vector. Supabase's documentation describes it as a Postgres extension for storing embeddings and performing vector similarity search, and mentions use in RAG.

The upside is that vectors live next to the rest of your data, so one query can filter by user, date or permission and rank by similarity. The catch, noted by Supabase, is that filtering on another column while using an approximate index can return fewer rows than you asked for. What breaks when pgvector is misunderstood: a team adds an index, sees results change and does not know that approximate search trades some recall for speed, or assumes a [vector database](/glossary/vector-database) feature such as managed scaling comes with the extension. A good next step is to run the same questions with and without the index and compare. The guide [What is RAG](/learn/what-is-rag) shows where retrieval fits, and [rag-chunking-planner](/skills/skill-almanac/rag-chunking-planner) tests what you store.

## Common confusions

- **pgvector versus a vector database.** pgvector adds vector search to Postgres. A dedicated [vector database](/glossary/vector-database) is a separate system built around vectors. Which suits you depends on your data and operations, so this page makes no ranking.
- **Exact versus approximate search.** By default pgvector searches exactly. An index makes it approximate, which the README says trades some recall for speed.
- **HNSW versus IVFFlat.** Both are approximate index types in the README. It describes HNSW as a multilayer graph and IVFFlat as dividing vectors into lists.
- **Myth.** pgvector creates embeddings. It stores and compares them. A separate model produces the vectors.

## Worked examples in this catalogue

### [What Is RAG? Retrieval-Augmented Generation Explained](https://skillalmanac.com/learn/what-is-rag)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The guide explains the indexing and query phases of retrieval-augmented generation, in which stored passages are found by similarity to the question.

Why it exercises the concept: A pgvector table can serve as the store that holds the vectors and answers the nearest-passage query in those phases. The guide shows the pipeline around that store.

### [rag-chunking-planner](https://skillalmanac.com/skills/skill-almanac/rag-chunking-planner)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Your documents split by three chunking strategies, with defects and offline recall reported for each, so chunk settings are chosen with numbers.

Why it exercises the concept: The rows you put in a vector table are chunks. This skill helps choose chunk settings before they are embedded and stored. It does not touch Postgres.

### [library-docs-lookup](https://skillalmanac.com/skills/skill-almanac/library-docs-lookup)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: An answer to a library question drawn from the installed package's own files, with file and line cited.

Why it exercises the concept: When an agent writes code that uses a pgvector client library, this skill points it at the installed package's own files rather than memory of an older API.

## Related terms

- [Vector database](https://skillalmanac.com/glossary/vector-database.md)
- [Embedding](https://skillalmanac.com/glossary/embedding.md)
- [Semantic search](https://skillalmanac.com/glossary/semantic-search.md)
- [Retrieval-augmented generation (RAG)](https://skillalmanac.com/glossary/retrieval-augmented-generation.md)
- [Cosine similarity](https://skillalmanac.com/glossary/cosine-similarity.md)

## Sources

- [pgvector: Open-source vector similarity search for Postgres](https://github.com/pgvector/pgvector), pgvector project (GitHub) (accessed 2026-11-24)
- [pgvector: Embeddings and vector similarity](https://supabase.com/docs/guides/database/extensions/pgvector), Supabase (accessed 2026-11-24)
- [Packaging Related Objects into an Extension](https://www.postgresql.org/docs/current/extend-extensions.html), PostgreSQL Global Development Group (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
