nlqdb

Solve · Agent builders

Should I build my own agent memory on Postgres or buy it?

If you already run Postgres and are deciding whether to hand-roll agent memory, a memories table is easy to start and expensive to get right at scale. nlqdb is the buy answer: one MCP command gives your agent a real database it writes rows to and queries in English, with tenant isolation enforced in the engine.

The agent-SaaS builder already runs Postgres or Supabase, so the real build-vs-buy question isn't 'which memory vendor' — it's 'why not just add a memories table?' That's the honest default, and for one project it's the right one. It stops being right the moment memory goes multi-tenant: a hand-rolled WHERE agent_id = $1 leaks every account the one time it's forgotten, retention becomes a cron you maintain, and 'group memories by user this week' means owning a text-to-SQL layer too. The CREATE TABLE was the easy part.

The snippet that solves it.

> count of memories per user, highest first

What nlqdb does for this

  • Honest first: if you just need recall for one project, a memories table on the Postgres you already run is the right call.
  • Where DIY bites: one command — claude mcp add --transport http nlqdb https://mcp.nlqdb.com/mcp — gives your agent a real hosted Postgres instead.
  • Tenant isolation is in the engine: a fail-closed tenant_isolation RLS policy keyed on app.tenant_id, not a WHERE filter you must remember to write.
  • Analytics come free: ask 'memories per user this week' in English and nlqdb compiles the GROUP BY, runs it, and shows the SQL.

Drop into any HTML page

<nlq-data goal="count of memories per user, highest first"></nlq-data>

The rollup a DIY memories table gives you only after you also build the query layer — group, count, order — answered here from one English goal.

What this replaces

What nlqdb doesn't try to do here

  • The opinionated agent_memory_v1 preset (facts/episodes/entities) is live but signed-in only — an anonymous agent still designs its own tables or provisions them from the first English goal.
  • Per-agent and per-end-user row scoping within one shared database is enforced in the engine (restrictive RLS keyed on app.agent_id), but the narrowing fields are HTTP-only today — the SDK, CLI, and MCP tools don't send them yet.
  • Writes go through the SDK or a signed-in POST /v1/run, not the public embed — the public <nlq-data> key is read-scoped, so a write credential must never sit in client HTML.

Questions buyers ask

Should I build my own agent memory or buy it?
If you need recall for a single project, build it — a memories table on the Postgres you already run is the honest, zero-vendor answer. The build cost shows up later: multi-tenant isolation that fails closed, a retention story, and analytical queries over what you stored. nlqdb is the buy answer once those must be correct at scale — one MCP command, a real hosted Postgres, tenant-isolation RLS in the engine, and NL analytics with the SQL shown.
What does a DIY memories table on Postgres cost me later?
The CREATE TABLE is the easy 20%. The expensive 80% is isolation you can't forget (a hand-rolled WHERE agent_id = $1 leaks every tenant the one time it's dropped; RLS doesn't), a TTL sweep instead of a forgotten cron, and a text-to-SQL trust boundary if you ever want to GROUP BY over memory in English. DIY wins on control; it loses once those must be correct.
How do I switch from a DIY table to nlqdb?
Run one command — claude mcp add --transport http nlqdb https://mcp.nlqdb.com/mcp — and your coding agent (Claude Code, Cursor, Codex) gets a real database it queries in English with nlqdb_query. The agent writes memory rows through the SDK or a signed-in POST /v1/run, then reads and aggregates them back in English.
Can I expire old agent memory automatically instead of writing a cron?
The TTL story is a server-built, bound-cutoff DELETE swept per database rather than a cron you maintain — the core sweep logic ships; the scheduled Worker that runs it is landing. On a DIY table you own the whole retention job yourself. Until the scheduler is live, treat automatic expiry as in-progress, not a promise.

Where this pain shows up in public

Enduring discussion hubs where you can verify the theme without taking our word for it. We don't quote individual posts; we cite search-result and subreddit URLs that stay live as new threads land.

Try nlqdb in 30 seconds

No sign-in. The anonymous database lasts 72 hours; adopt it with one click if you keep it.

Start with a goal →

Looking at this from a different angle? Browse all solve pages or browse competitor comparisons.