Lab

AI memory: when SQL is enough, and when to test a graph

Short answer

Memory connects decisions, people, versions and events. That relational character makes a graph database an attractive possibility. We approached it by separating two questions: do these relationships improve answers, and is an additional storage engine needed to serve them?

A single source supports relationships and reading paths whose added complexity needs evaluation.

The useful relationship comes before the engine

A link from a decision to its replacement provides specific information. An author’s identity, the origin of a reformulation or the date of a change can also resolve uncertainty. Similarity between two texts does not provide the same assurances.

We therefore distinguished relationships established by the system’s structure from those extracted by a model. The former reflect known events, such as writing, replacement, membership or departure. The latter propose an interpretation of content.

This distinction helps identify the source of an improvement. An answer may become better because it receives provenance that was previously missing, without the choice of storage engine causing that benefit.

It also keeps the evaluation focused. Before comparing technologies, we need to know which information improves the answer and how reliable that information is.

What the relational benchmark revealed: scope and limits

The experiment compared reference retrieval, canonical relationships supplied with citations, and that structure supplemented with model-extracted relationships. A separate graph engine was also compared with the SQL service.

The synthetic corpus contains four test worlds, each with two organisations, and 240 questions in total. Cited relationships helped with provenance, handovers and history. A substantial share of the improvement came from canonical structure without model extraction.

The overall improvement was nevertheless insufficient to validate the complete approach. Dependency questions and a simple control regressed beyond the predefined limits. Extraction achieved high recall but precision of approximately 0.24: many proposed relationships did not match the benchmark’s expected truth.

That is an important difference between a promising average and an acceptable architecture. Adding links can improve a mean score while introducing unacceptable errors in a particular question family.

Why a second store must justify itself

In the scale experiments, SQL met the measured requirements up to five million edges. The graph engine won on some shortest-path queries, but did not establish a general SQL bottleneck that justified another store.

A separate check compared a projection maintained through successive changes with a complete reconstruction from the source. It found a divergence associated with an event missing from the maintenance process. A speed comparison alone would not have exposed that problem.

The architectural question therefore includes synchronisation, corrections and access rights. A derived representation needs to remain reconstructible and consistent after each relevant change. Two engines provide two ways to query information, together with additional state to maintain.

This makes operational complexity part of the result rather than an afterthought. A faster query is valuable only within a system that continues to return the correct, authorised information.

PostgreSQL with pgvector can search numerical representations. An approximate index such as HNSW can accelerate some searches, with a trade-off in recall and a cost for construction and writes.

An index being present does not establish that a query uses it. In the search shape we examined, grouping fragments by memory before sorting did not follow the access path expected by that index. The actual query plan matters more than the name of the installed technology.

Synthetic benchmarks also showed that usefulness depends on the volume being searched and the distribution of vectors. A fast configuration on one distribution can lose substantial recall on another. Response time alone is therefore an incomplete description of retrieval quality.

Choosing an architecture for durable memory

Our sequence is to identify missing information, measure the value of supplying it, and then examine a different engine if a bottleneck appears. Useful relationships can be served through SQL. A vector index needs evaluation against real query shapes and an exact-search reference.

The Lab results do not establish that SQL replaces every graph database, or that approximate indexes have no purpose. They explain why adding technology requires a demonstrated benefit for the problem at hand.

For Nawame, this discipline limits the complexity surrounding versions and access rights. It connects with incremental embeddings and measurement before adding complexity. Sovereignty also includes the ability to understand and control the representations of one’s memory.

Related reading: RAG, vector database or AI memory: which one do you need?.

Your next prompt should not have to contain your whole story.

Start building a memory your AI tools can find again when it matters.

Start free