Vector Storage for a Knowledge Base: Why Reusing the Primary Database Failed After Three Months

    A knowledge-base team first stored embeddings in its existing relational database to limit operations, keep metadata and vectors consistent, and match an expected scale of tens to hundreds of thousands of chunks. After three months, memory pressure, index rebuilds that interfered with business writes, and weak support for filtered and hybrid search led them to move vectors into a separate store. This article explains that decision, the failure modes, and practical criteria for when reuse is still reasonable.

    1. Background: Vector Search Is Hard to Avoid

    Teams building a knowledge-base system almost always hit the same problem. Documents are split into chunks, an embedding model turns those chunks into high-dimensional vectors, and those vectors are stored. At query time, the user’s question is embedded as well, the store returns the most similar chunks, and a large language model uses them to compose an answer.

    The critical step in that flow is vector storage and similarity search. Two intuitive industry approaches exist:

    • Introduce a dedicated vector database, deployed and operated on its own.
    • Add vector search to the existing relational database, so the current store takes on the new workload.

    Our team started with the second option. The reasons were solid in that context. Three months later we reversed the decision, and the lessons from that process are worth spelling out.

    2. Why We First Put Vectors Back in the Existing Database

    2.1 Three Practical Considerations at Decision Time

    First, minimize the operations surface. The system already used a relational database for business data, and the team had no dedicated DBA. Adding another stateful storage component meant another set of backup, monitoring, upgrade, and failure-drill procedures. For a knowledge-base project still in validation, that cost was not small.

    Second, consistency came for free. Knowledge-base metadata—document source, permissions, update time, and similar fields—already lived in the primary database. If vectors and metadata shared that database, one transaction could keep “document updated, vector updated” in sync, without dual writes or reconciliation.

    Third, the scale forecast was optimistic. We expected tens of thousands to a few hundred thousand chunks. Intuitively, a general-purpose database plus a vector extension would be enough.

    2.2 The Technical Path Was Real

    Most mainstream relational databases offer some vector extension. The core idea is usually:

    1. A new column type that stores a fixed-length array of floats.
    2. Distance functions such as inner product, cosine distance, and Euclidean distance.
    3. Specialized indexes—typically approximate nearest-neighbor structures such as quantization-based graph indexes or inverted-file indexes—to speed similarity ranking in high-dimensional space.

    A table might look like this:

    1. CREATE TABLE embeddings (
    2. embedding_id UUID PRIMARY KEY,
    3. embedding vector(768), -- must match the embedding model's output dimension
    4. text TEXT,
    5. metadata JSONB
    6. );

    A few engineering points matter:

    • Dimensions must match the model. Common sizes such as 768, 1024, and 1536 depend on the embedding model. Changing models means rebuilding the index and, in practice, the table.
    • Do not leave the vector column unbounded. Declaring the dimension lets the database optimize storage layout and reject bad data when the index is created.
    • Semi-structured metadata is convenient. It supports filtered search by document ID, section, permission label, and similar fields, which knowledge bases need often.

    3. What Broke After Three Months

    3.1 The Performance Curve Was Steeper Than Expected

    Vector-index memory use grows roughly linearly with data volume, and for recall quality the index often needs to stay fully in memory. As chunk counts moved from a few hundred thousand toward tens of millions, the vector index consumed a large share of the primary database’s memory budget. Cache space for ordinary business tables shrank, and overall performance degraded in several places at once.

    3.2 Index Builds and Writes Interfered with Each Other

    Nearest-neighbor indexes are expensive to build during heavy writes. Rebuilding the knowledge base—for example after a new chunking strategy or a new embedding model—rewrites every vector. During that rebuild, write latency on the primary database rose sharply and even affected availability of normal business tables. Vector load and business load shared one database, so the resources could not be isolated.

    3.3 A Ceiling on Retrieval Capability

    Knowledge-base search often needs mixed queries: vector similarity plus scalar filters, such as “find similar chunks only inside one department’s documents.” In a general-purpose database, plan quality for these queries is easy to get wrong. Whether the filter runs first or the index scan runs first directly affects recall and latency. High-quality answers also need hybrid retrieval—keyword scores and vector scores fused and reranked—which a general database forces you to glue together yourself.

    4. The Later Architecture and What We Took From It

    We eventually split vectors out. A dedicated vector store handles retrieval; the primary database still holds metadata and business data. The two are linked by document ID, and asynchronous jobs provide eventual consistency.

    A few reusable criteria came out of the project:

    1. Scale is the first decision variable. Below a few hundred thousand chunks, with infrequent writes, reusing the primary database is reasonable and economical. At tens of millions of chunks, or with frequent writes, a separate vector store starts to pay off.
    2. Decide hybrid retrieval needs early. If the product depends on filtered similarity search or multi-path recall and reranking, leave room for those capabilities at selection time instead of bolting them on after performance problems appear.
    3. Watch recall, not only latency. Approximate indexes trade recall for speed. Before launch, measure top-k hit quality on real query samples.
    4. Architecture decisions can be reversed if you leave an exit. Vectors are derived data and can be regenerated by re-embedding the source text. Script and parameterize that pipeline, and the migration cost stays acceptable.

    There is no one-step answer for this choice. What matters is an architecture that can evolve with scale: validate value with the simplest workable design, and keep a boundary ready for a split. That is what lets a knowledge-base system grow without getting stuck.