# pgvector

> Embeddings next to the data they describe, for when a user is waiting for the answer.

- Verdict: My default
- Vendor: Postgres extension
- Layer: [AI](https://cloudlesslabs.com/stack/layers/ai.md). Job: Vectors in your app's database
- Last reviewed: 18 October 2026, by Nicolas Dao (Cloudless Labs, Sydney)
- Web page: https://cloudlesslabs.com/stack/pgvector/. The whole stack in one file: https://cloudlesslabs.com/stack/brief.md

pgvector is my default for embeddings because the vectors live with the business data. One query can join, filter by tenant and permissions, mix keyword and semantic search, and answer in milliseconds.

## Use it when

- Product or document search inside an app, a support chatbot over a client's knowledge base, 'similar items', duplicate detection.
- Results must be filtered by permissions, client, status or dates with SQL joins and row-level security.
- Keyword and semantic search together (hybrid).
- Answers in milliseconds (about 3–9 ms).
- Up to a few million vectors.

## Don't use it when

- Tens of millions of vectors queried rarely: the index must fit in RAM (10M vectors ≈ 77 GB). Use S3 Vectors.

## Pricing

Mostly the storage on a Postgres you already pay for: about $5 a month for 1M vectors on an existing Neon database.

## Gotchas, with fixes

- **Gotcha:** The HNSW index has to fit in memory, so large collections force a big, always-on database.
  **Fix:** Keep the hot data in pgvector and move the archive to S3 Vectors. Watch Neon's Lakebase Search, which keeps the index on disk.

## Instead, consider

- [Amazon S3 Vectors](https://cloudlesslabs.com/stack/aws-s3-vectors/index.md): Huge, cold or per-client collections.

## Worked examples

- [pgvector or S3 Vectors?](https://cloudlesslabs.com/stack/guides/vectors/index.md): Where should my embeddings live?

## Where it fits

- [An AI chat or LLM feature](https://cloudlesslabs.com/stack/use-cases/ai-chat.md): pick 3. If the answers need your data (RAG).
- [Semantic search and RAG](https://cloudlesslabs.com/stack/use-cases/search.md): pick 1. When a user is waiting and results depend on your data and permissions.

## Sources

- [pgvector](https://github.com/pgvector/pgvector)

## Related

- [AI](https://cloudlesslabs.com/stack/layers/ai.md): every tool in this layer, with its verdict
- [The whole stack in one file](https://cloudlesslabs.com/stack/brief.md): every use case and tool, for questions that span many
- [Map of every Markdown file on cloudlesslabs.com, with what each one answers](https://ask.cloudlesslabs.com)
