Sub topic 15
Choosing between libraries, extensions and dedicated databases
This chapter assumes you know what embeddings are, how HNSW and IVF indexes trade recall for speed, and how metadata filters and hybrid search work. It helps you pick a system for a given workload.
The three categories
Every vector search system falls into one of three groups. Each gives you a different amount of infrastructure around the index.
- Vector libraries such as FAISS run inside your process. They give you fast indexes and nothing else. You manage persistence, updates, metadata and serving yourself.
- Extensions to relational databases such as pgvector add a vector column type and indexes to a database you already run. You get transactions, SQL joins and backups.
- Dedicated vector databases are separate services built around vector search. They typically provide sharding, replication, filtering and hybrid search as built-in features.
Comparing them on the dimensions that matter
| Dimension | Library | Relational extension | Dedicated database |
|---|---|---|---|
| Setup effort | Low, but you build the rest | Low if you already run the database | Medium, a new service to operate |
| Transactions with other data | None | Full ACID with your tables | Usually limited |
| Metadata filtering | You write it | SQL `WHERE` and joins | Built in, often optimized |
| Scaling beyond one machine | Manual | Limited, depends on the host database | Designed for sharding and replicas |
| Index choices | Widest range | Few, usually HNSW and IVF | Varies, often HNSW plus compression |
| Operational cost | Your code | One system | Another system to monitor and pay for |
Criteria that decide the choice
- Data size and memory. HNSW wants the graph and vectors in RAM. At hundreds of millions of vectors, you need compression such as product quantization or sharding. Dedicated systems handle this more directly.
- Update pattern. A static corpus rebuilt nightly suits a library. Constant inserts and deletes need a system that manages them for you.
- Filter selectivity. A filter that keeps only 1% of rows can starve an HNSW search of candidates. Test your filters on the real system, because filtered recall differs between implementations.
- Consistency. If an embedding must change atomically with its source row, a relational extension gives you that for free.
- Team and operations. A new service means new monitoring, upgrades and failure modes. If the team already runs Postgres well, that has real value.
Common errors
- Choosing by benchmark headline. Published recall and speed numbers depend on dataset, dimensions and settings. Measure on your own data with the recall method from the evaluation chapter.
- Adopting a dedicated database for a small corpus. A few hundred thousand vectors fit in pgvector with room to spare.
- Ignoring migration cost. Embeddings depend on the model that produced them. Changing the model means re-embedding everything, whichever system you choose, so keep the source data.
- Forgetting the filter in the benchmark. A system that is fast on pure vector queries can be slow once a
WHEREclause is added.
A quick worked decision
A support team has 400,000 help articles, stored in Postgres, updated hourly, and each search must filter by product and language. The data is small, the filters are relational, and updates must stay consistent with the article rows. pgvector fits. If the corpus grew to 200 million vectors with thousands of queries per second, the memory and sharding needs would point to a dedicated database.
Exercise
A team has 50 million product embeddings that change constantly, serves thousands of queries per second, and filters by price and category. Which category is the best starting point, and what is the main reason?
Show answer
A dedicated vector database. The data size, query rate and constant updates call for built-in sharding, replication and optimized filtered search, which a single-machine library or a general database extension handles less well. They should still benchmark filtered recall and latency on their own data before committing.