DEV Community

Cover image for Why SQLite+FTS5 beats Vector DBs for AI Agent Memory
Fex Beck
Fex Beck

Posted on

Why SQLite+FTS5 beats Vector DBs for AI Agent Memory

The conventional wisdom is wrong

Everyone says you need a vector database for AI memory. Pinecone, Weaviate, Qdrant. They all need a server, an API key, and a monthly bill.

I went a different way: SQLite + FTS5. One file. Zero dependencies. Better results.

How it works

BrainDB stores 4,300+ memories in a single SQLite file with three search modes:

1. Full-text search (FTS5) — Sub-millisecond keyword search with BM25 ranking.

2. Embedding similarity — 384-dim vectors stored as BLOBs, cosine similarity computed in TypeScript.

3. Hybrid search — Reciprocal Rank Fusion combines both for best-of-both-worlds retrieval.

Custom relevance scoring

SQLite custom functions run type-aware ranking inside the database:

  • Decisions get +0.3 boost (authoritative)
  • Issues get -0.1 (often resolved)
  • Superseded memories return 0
  • Exponential time decay with type-specific half-lives

The numbers

Metric SQLite+FTS5 Pinecone Free
Latency <1ms 50-200ms
Setup 0 minutes 15 minutes
Cost $0 $0-70/mo
Backup cp file.db backup.db API call
Offline Yes No

For most AI agent memory use cases, SQLite is the right choice.

Try it: github.com/beckfexx/BrainDB — AGPL-3.0, TypeScript, Bun.

Top comments (0)