Everyone's trying vectors and graphs for AI memory. We went back to SQL

136 points by Arindam1729 ↗ HN
When we first started building with LLMs, the gap was obvious: they could reason well in the moment, but forgot everything as soon as the conversation moved on.

You could tell an agent, “I don’t like coffee,” and three steps later it would suggest espresso again. It wasn’t broken logic, it was missing memory.

Over the past few years, people have tried a bunch of ways to fix it:

1. Prompt stuffing / fine-tuning – Keep prepending history. Works for short chats, but tokens and cost explode fast.

2. Vector databases (RAG) – Store embeddings in Pinecone/Weaviate. Recall is semantic, but retrieval is noisy and loses structure.

3. Graph databases – Build entity-relationship graphs. Great for reasoning, but hard to scale and maintain.

4. Hybrid systems – Mix vectors, graphs, key-value, and relational DBs. Flexible but complex.

And then there’s the twist: Relational databases! Yes, the tech that’s been running banks and social media for decades is looking like one of the most practical ways to give AI persistent memory.

Instead of exotic stores, you can:

- Keep short-term vs long-term memory in SQL tables

- Store entities, rules, and preferences as structured records

- Promote important facts into permanent memory

- Use joins and indexes for retrieval

This is the approach we’ve been working on at Gibson. We built an open-source project called Memori (https://memori.gibsonai.com/), a multi-agent memory engine that gives your AI agents human-like memory.

It’s kind of ironic, after all the hype around vectors and graphs, one of the best answers to AI memory might be the tech we’ve trusted for 50+ years.

I would love to know your thoughts about our approach!

26 comments

[ 2.8 ms ] story [ 61.3 ms ] thread
Who would've thought that 50 years of 'SELECT * FROM reality' might beat the latest semantic embedding wizardry?
How does Memori choose what part of past conversations is relevant to the current conversation? Is there some maximum amount of memory it can feasibly handle before it will spam the context with irrelevant "memories"?
Looking at the code, it looks like they do about 5 'memories' that get retrieved by a database query designed by an LLM with this fella:

SYSTEM_PROMPT = """You are a Memory Search Agent responsible for understanding user queries and planning effective memory retrieval strategies.

Your primary functions: 1. *Analyze Query Intent*: Understand what the user is actually looking for 2. *Extract Search Parameters*: Identify key entities, topics, and concepts 3. *Plan Search Strategy*: Recommend the best approach to find relevant memories 4. *Filter Recommendations*: Suggest appropriate filters for category, importance, etc.

*MEMORY CATEGORIES AVAILABLE:* - *fact*: Factual information, definitions, technical details, specific data points - *preference*: User preferences, likes/dislikes, settings, personal choices, opinions - *skill*: Skills, abilities, competencies, learning progress, expertise levels - *context*: Project context, work environment, current situations, background info - *rule*: Rules, policies, procedures, guidelines, constraints

*SEARCH STRATEGIES:* - *keyword_search*: Direct keyword/phrase matching in content - *entity_search*: Search by specific entities (people, technologies, topics) - *category_filter*: Filter by memory categories - *importance_filter*: Filter by importance levels - *temporal_filter*: Search within specific time ranges - *semantic_search*: Conceptual/meaning-based search

*QUERY INTERPRETATION GUIDELINES:* - "What did I learn about X?" → Focus on facts and skills related to X - "My preferences for Y" → Focus on preference category - "Rules about Z" → Focus on rule category - "Recent work on A" → Temporal filter + context/skill categories - "Important information about B" → Importance filter + keyword search

Be strategic and comprehensive in your search planning."""

How does what you've described solve the coffee/espresso problem? You can't query SQL such that records like 'espresso' return coffee?
>It wasn’t broken logic, it was missing memory.

sigh

SELECT 'Hacked!' AS result FROM Gibson_AI WHERE memory='SQL' AND NOT EXISTS ( SELECT 1 FROM vector_graph_hype WHERE recall > ( SELECT speed FROM relational_magic WHERE tech='50_years_old' ) )
Any reason I should pick it over Supabase? https://supabase.com/docs/guides/ai

They have pgvector, which has practically all the benefits of postgres (ACID, etc, which may not be in many other vector DBs). If I wanted a keyword search, it works well. If I wanted vector search, that's there too.

I'm not keen on having another layer on top especially when it takes about 15 mins to vibe code a database query - there's all kinds of problems with abstracted layers and it's not a particularly complex bit of code.

> multi-agent memory engine that gives your AI agents human-like memory

What does this do exactly?

(comment deleted)
You gotta refactor the code around the mongodb integration. It's basically duplicating your data access paths.
IMHO all these approaches are hacks on top of existing systems. The real solution is going to be when foundational models are given a mechanism that makes them capable of storing and retrieving their own internal representation of concepts/ideas.
I tried a graph based approach in my previous product (1). I am on a new product now and I came back to SQLite. Initially it was because I just wanted a simple DB to enable creating cross-platform desktop apps.

I realized LLMs are really good at using sqlite3 and SQL statements. So in my current product (2) I am planning to keep all project data in SQLite. I am creating a self-hosted AI coding platform and I debated where to keep project state for LLMs. I thought of JSON/NDJSON files (3) but I am gravitating toward SQLite and figuring out the models at the moment (4).

  1. Previous product with a graph data approach https://github.com/pixlie/PixlieAI
  2. Current product with SQLite for its own and other projects data: https://github.com/brainless/nocodo
  3. Github issue on JSON/NDJSON based data for project state for LLMs: https://github.com/brainless/nocodo/issues/114
  4. Github issue on expanding the SQLite approach: https://github.com/brainless/nocodo/issues/141
Still work in progress, but I am heading toward SQLite for LLM state.
As context window sizes increase and token prices go down, it makes more sense to inject dynamic memories into context (and use RAG/vector stores for knowledge retrieval).
The relational model is built on first order / predicate logic. While SQL itself is kind of a dubious and low grade implementation of it, it's not a surprise to me that it would be useful for applications of reasoning and memory about facts generally.

I think a Datalog type dialect would be more appropriate, myself. Maybe something like that RelationalAI has implemented.

This looks like RAG...? That's fine, RAG is a very broad approach and there's lots to be done with it. But it's not distinct from RAG.

Searching by embedding is just a way to construct queries, like ILIKE or tsvector. It works pretty nicely, but it's not distinct from SQL given pg_vector/etc.

The more distinctive feature here seems to be some kind of proxy (or monkeypatching?) – is it rewriting prompts on the way out to add memories to the prompt, and creating memories from the incoming responses? That's clever (but I'd never want to deploy that).

From another comment it seems like you are doing an LLM-driven query phase. That's a valid approach in RAG. Maybe these all work together well, but SQL seems like an aside. And it's already how lots of normal RAG or memory systems are built, it doesn't seem particularly unique...?

So HN is upvoting AI written ad slop now?
Have you considered using prolog as a database instead of mysql?

Good ways to store relations, iterating weird combinations, filling the blanks

I think Datalog would be even more suitable than Prolog for this use case.
This is exactly the lesson we learned as well but didnt want to publish. Relational data stores are desperately underrated for LLM retrieval especially concerning things like personality and memory
Sometimes I think we need to expose what 'memories' or their semantic representation has been stored in a 'memory store' so that humans can review and verify it over time. This will help the LLM 'forget' things that the humans using it don't really think is that relevant.