Book a free call

Vector Database Best Practices for Production RAG

Vector database best practices cover embedding choice, index design, metadata filters and measured recall, so search stays fast and accurate at any scale.

Hertiv engineering teamReviewed by a senior engineer
6 min read
Vector Database Best Practices for Production RAG
On this page

Short answer

Vector database best practices are the design and operating rules that keep similarity search fast, accurate and affordable in production: pick one embedding model and freeze it, index for your query pattern, store metadata for filtering, refresh changed records, and measure recall on real queries instead of guessing.

What are vector database best practices?

Vector database best practices are the design and operating rules that keep similarity search fast, accurate and affordable once a retrieval system is in production. A vector database stores embeddings, which are number lists that capture the meaning of text, images or other content, and returns the items closest to a query embedding.

The practices cover five areas: the embedding model, the index, the metadata you store beside each vector, how you keep data fresh, and how you measure quality. Getting any one of these wrong shows up as slow queries, wrong answers or a bill that grows faster than your collection.

Most teams start with a small prototype and only meet the hard problems later, when the collection passes a few hundred thousand vectors or when users ask questions the prototype never saw. The rules below are written for that second stage, when the database has to work every day. For the basics of what a vector store is, see what is a vector database.

How do you pick an embedding model and dimension?

Pick one embedding model and freeze it, because changing models means re-embedding the whole collection. Compare two or three models on your own queries first, using a small labelled set of questions and the passages that should answer them, then choose the one with the best recall for your content.

Dimension is the length of each embedding, and larger is not always better. A 1,536-dimension model stores more detail than a 384-dimension one, but it also uses more memory and slows search. If your queries are short and your documents are similar in style, a smaller model often matches the larger one on recall while costing less to run.

Model size When it fits Trade-off
Small, around 384 dimensions Short queries and similar documents Fast and cheap, less detail
Medium, around 768 dimensions Mixed content and general search Balanced speed and detail
Large, around 1,536 dimensions Varied content where nuance matters Most detail, most memory

Keep the model version in your records. When a vendor ships a new version, treat it as a migration: embed a sample with both versions, compare recall, and only switch after the new version proves better on your own test set.

Design the index for your query pattern, not for a benchmark. The common choice is an approximate nearest neighbour index such as HNSW, which trades a small amount of accuracy for much faster search, and it fits most production workloads once the collection grows past a few tens of thousands of vectors.

Tune the index settings on your own data. A higher search width returns better recall but costs more time per query, so measure both: run your test queries, record recall and latency, and pick the setting where recall stops improving much while latency stays inside your budget.

Do not return too many results and hope the language model sorts them out. Returning the top five or ten passages is usually enough, and adding a reranking step on that short list improves answer quality more than returning fifty passages ever does.

What metadata and filters should you store?

Store metadata beside every vector so you can filter before you search. Useful fields include the source document, the date, the author or owner, the language, and any access level that decides who may see the passage. Filters turn a broad search into a narrow one, which is both faster and safer.

Metadata also makes results explainable. When a user asks where an answer came from, you can show the source document and the date it was written, instead of pointing at a bare similarity score that means nothing to a reader.

Keep metadata in the same write as the vector. If the two are stored separately and one update fails, the database ends up with vectors that point at documents that no longer exist, or documents with no vectors at all. A single write path keeps them in step. Vector databases compared with traditional databases explains why this pairing matters.

How do you keep vectors fresh and consistent?

Keep vectors fresh by treating every document change as an event. When a document is created, edited or deleted, queue a job that re-embeds the changed chunks and removes the old vectors. A nightly batch job can catch anything the event queue missed, but it should not be the only mechanism.

Chunk documents in a stable way so that small edits do not rewrite the whole record. Splitting by paragraph or by section, with a little overlap between neighbours, means an edit to one paragraph only affects one or two chunks, which keeps re-embedding cheap and fast.

Watch for duplicates. The same document uploaded twice, or the same paragraph in two files, will return twice in search results and waste the language model's attention. A hash of each chunk's text is a simple way to spot duplicates before they are stored.

How do you measure retrieval quality?

Measure retrieval quality with a fixed test set of real questions and the passages that should answer them. Run the set after every change to the embedding model, the chunking rules or the index settings, and record recall: how often the right passage appears in the top five results.

Add a second measure for the end user: how often the final answer is correct and grounded in a cited passage. Retrieval recall can look good while answers stay wrong, for example when the retrieved passage is relevant but the model ignores it. Track both numbers together.

Log real queries and sample them weekly. A query that returns nothing, or that returns the same wrong passage again and again, is a signal that a document is missing, a chunk boundary cut a key sentence, or the embedding model does not understand your domain terms. See best vector databases for startups for the tools teams commonly compare.

Example (hypothetical): a support team moves to RAG

Example (hypothetical): a support team with 40,000 help-centre articles and 3,000 past tickets builds a retrieval system for its agents. It embeds each article in chunks of about 400 words, stores the article title, date and product area as metadata, and uses an HNSW index.

The team builds a test set of 120 real questions with the correct article for each. The first run returns the right article in the top five results for 88 of the 120 questions, a recall of about 73%. The team finds that most failures come from articles split across chunk boundaries, so it adds 50 words of overlap between neighbours and re-runs the test.

Recall rises to 102 of 120, about 85%. The team then adds a reranking step on the top ten results and reaches 108 of 120, about 90%. Each change is measured on the same test set, so the team knows which change helped and by how much, instead of debating opinions.

What are the common mistakes?

The most common vector database mistakes are switching embedding models without a migration plan, storing vectors without metadata, and never measuring recall after launch.

  • Changing models casually. A new model version means re-embedding everything; without a plan, half the collection ends up on the old model and half on the new one.
  • No metadata filters. Searching the whole collection for every query is slower and returns passages the user should never see.
  • Chunks that are too large or too small. Whole documents bury the answer, while single sentences lose the context the model needs.
  • Stale data. If edits never trigger re-embedding, the system answers from last year's documents.
  • No test set. Without fixed questions and expected answers, every change is a guess.
  • Returning too many results. Flooding the model with fifty passages costs tokens and rarely improves the answer.

Key takeaways

  • Freeze one embedding model and record its version, so a switch is a planned migration
  • Filter with metadata before searching, so results stay fast, relevant and safe to show
  • Chunk by paragraph or section with overlap, so small edits only affect a few vectors
  • Measure recall on a fixed test set after every change to the model, chunking or index
  • Re-embed changed documents on an event, not only in a nightly batch

Frequently asked questions

Do I need a vector database for a small RAG project?

Not always. A few thousand documents can work with a simple in-memory store or even keyword search. A vector database earns its place when the collection grows, when queries need semantic matching, or when several services must share the same index safely.

How many vectors can a vector database hold?

Modern vector databases hold tens of millions of vectors on a single node and far more across a cluster. The practical limit is usually memory and cost, not the software, so check how much RAM your index needs at your planned collection size before you commit.

Should I use HNSW or an exact search index?

Use HNSW once the collection passes a few tens of thousands of vectors, because exact search slows down linearly with size. Exact search is fine for small collections and for testing, where you want a true baseline to compare the approximate index against.

How often should I re-embed my documents?

Re-embed a document whenever it changes, and run a full check on a schedule that matches how fast your content moves. Weekly is enough for stable help centres; daily or faster fits product docs that change with every release.

Can I mix keyword search with vector search?

Yes, and most production systems do. Keyword search catches exact terms such as product codes and names, while vector search catches meaning. Combine the two scores, then rerank the merged shortlist for the best results.

What is the biggest cost driver in a vector database?

Memory for the index and the embeddings is usually the biggest cost, followed by the compute for embedding new documents. Smaller dimensions, metadata filtering and sensible chunk sizes all reduce memory, while batching embedding calls reduces compute cost.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a RAG system or an AI agent on your own data? Talk to Hertiv.

A senior engineer replies within one business day. Or see our RAG Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call