Insights · Generative AI & Agentic AI

Why RAG Performance Depends
on the Same Discipline as Database Indexing

An AI system that retrieves answers from an organisation's own data will slow down at scale for a familiar reason — the same reason a database slows down without proper indexing and partitioning. The discipline that fixes it is not new. It is exactly the discipline infrastructure teams already apply to every database they operate.

A question every DBA already knows the answer to

Can a table be created without an index? Yes. Can it be created without a partitioning strategy? Also yes. Neither is required for the table to function. But every infrastructure team knows what happens as the data volume grows — the queries that returned instantly at a thousand rows begin taking seconds, then longer, at a million.

The same conversation applies directly to AI retrieval systems, and for the same underlying reason. A knowledge base of ten documents will return an answer instantly with no optimisation at all. A knowledge base of ten million documents will not — unless the same architectural discipline that governs traditional databases is applied to it.

Why an unindexed knowledge base becomes slow

When an AI system searches for the answer most relevant to a query, without any structure applied to the underlying data, it has to compare that query against every single entry in the knowledge base to find the closest match. This is the direct equivalent of a full table scan — checking every row because there is no index to jump directly to the relevant subset.

The fix is the same in principle as it is in a traditional database: segment the data so that a search only has to work through a relevant subset rather than the entire knowledge base. In AI retrieval, this segmentation is typically referred to as chunking — dividing a large body of information into smaller, logically grouped sections before it is indexed. A query about one subject area does not need to be compared against content from an entirely unrelated domain, in the same way a query for a specific customer record does not benefit from scanning transaction data outside that customer's partition.

The parallel goes further. In traditional databases, partitioning on a column with very high uniqueness — a primary key, for instance — is generally discouraged, because it creates too many partitions, each holding too little data to make the partitioning worthwhile. The same principle applies to how a knowledge base is segmented for AI retrieval: segments that are too narrow create management overhead without a meaningful performance gain, while segments that are too broad reintroduce the original scanning problem.

Two different ways a system can search

A second architectural decision worth understanding is the difference between two ways a search can be evaluated — one based on matching a pattern, and one based on understanding meaning.

Pattern-based matching finds content that structurally resembles the query — similar wording, similar phrasing. Meaning-based matching goes further: it can return content that uses completely different words but addresses the same underlying question. A knowledge base containing vehicle specifications and their fuel consumption figures can correctly answer a question about "fuel efficiency" even if that exact phrase never appears anywhere in the source data — because the system is matching on meaning, not on matching text patterns.

This distinction has direct implications for how a knowledge base should be prepared and which retrieval approach is appropriate for a given use case. A system built for precise document lookup — legal clauses, exact policy wording — may be better served by pattern-oriented matching, where exact phrasing matters. A system built to answer open-ended questions from a broad knowledge base benefits from meaning-based matching, where the objective is understanding intent rather than finding a literal string match.

Routing — sending the right query to the right model

A more advanced pattern worth planning for early is routing — directing different types of queries to different underlying models based on what the query actually requires. This is a familiar concept dressed in new terminology. It is the same principle behind a network router directing traffic based on destination, or an ETL pipeline routing records to different processing paths based on a condition.

In an AI deployment, this means a single system can maintain more than one specialised model behind the scenes — one tuned for precise document lookup, another tuned for open-ended conversational queries, another for structured data analysis — and route each incoming query to whichever is best suited, rather than forcing every request through a single general-purpose model regardless of fit.

Designing for this from the outset avoids a common failure mode: a single model handling every type of request adequately, but none of them well.

Why this matters before scale, not after

In a proof-of-concept environment with a small dataset, none of this indexing, segmentation, or routing discipline is strictly necessary — the system will perform adequately regardless. The risk is treating the proof-of-concept architecture as production-ready without revisiting these decisions once real data volume arrives.

This is precisely the same trap infrastructure teams have learned to avoid with traditional databases — the schema that worked perfectly in staging with sample data, and then needed a redesign under production load because indexing and partitioning were never properly planned. AI retrieval systems fail in exactly the same pattern, for exactly the same reason, and the fix is exactly the same discipline: design the segmentation and indexing strategy deliberately, before the data volume makes the absence of one expensive to fix.