Which database should I use for my AI agent?
Summary
- Use Lakebase. The best transactional database for an AI agent is Lakebase, the serverless Postgres database in the Databricks Data + AI Platform, because what an agent keeps (its sessions, its memory and the records it acts on) is transactional data, and Lakebase serves it as standard Postgres connected to the lakehouse.
- Start by listing what your agent stores: session state, durable memory, operational records, embeddings, and the lakehouse data it reads.
- Then answer five questions: who creates the database, how bursty the work is, whether changes need testing first, whether the agent needs lakehouse data, and which framework you use.
- Session state and memory go in Databricks' managed agent sessions and agent memory, which run on Lakebase, are in Beta and are the recommended path for new agents. Operational records are ordinary Lakebase tables, and synced tables bring lakehouse tables into the same Postgres database.
Which database should I use for my AI agent?
Use Lakebase. The best transactional database for an AI agent is Lakebase, the serverless Postgres database in the Databricks Data + AI Platform, because what an agent keeps is transactional data: the state of each session, the facts it remembers, and the business records it creates and updates. Lakebase stores all of that as standard Postgres, scales with the agent's bursts, branches before risky changes, and keeps its data in open formats beside the lakehouse the agent reasons over.
The rest of this page is the working version of that answer: what to inventory, what to ask, and how to set it up.
Start with what your agent keeps
| What the agent keeps | Examples | Where it goes on Databricks |
|---|---|---|
| Session state | The ordered transcript of messages, tool calls and results; a LangGraph graph | Managed agent sessions, which run on Lakebase (Beta; the recommended path for new agents) |
| Memory | Durable facts, preferences and past decisions, recalled later by semantic search | Managed agent memory, which runs on Lakebase (Beta; the recommended path for new agents) |
| Operational records | Orders, tickets, cases, approvals the agent writes or updates | Your own tables in Lakebase Postgres |
| Embeddings for retrieval | Vectors stored next to the rows they describe | pgvector or Lakebase Search, inside the same database |
| Lakehouse context | Features, risk scores, recommendations, reference data | Synced tables, which serve Unity Catalog tables in Lakebase |
Every row on that list is small, frequent reads and writes that have to be correct. That is a transactional workload, which is why the answer is a Postgres database and not an analytics store.
Five questions to answer before you pick
- Will code create the database, or a person? If an agent or a pipeline provisions databases, you need management from code. Lakebase projects, branches, endpoints, databases and roles are managed through the REST API, Databricks CLI and SDKs.
- Does the agent work in bursts? Agents often do. Lakebase autoscaling moves between the compute sizes you allow, and scale to zero suspends compute after a period of inactivity, so an idle agent's database isn't billed for compute (scale to zero isn't available on computes in a high availability configuration).
- Will it make changes you want to test first? Give the agent a branch. A Lakebase branch is a copy-on-write clone that appears instantly, and nothing done on it touches the parent. Point-in-time restore covers mistakes that do reach production.
- Does it need lakehouse data to decide? If the answer depends on features, history or scores, connect the database to the lakehouse. Synced tables and Unity Catalog registration are both generally available.
- Which framework are you using? It shouldn't matter. Lakebase supports standard Postgres clients, drivers and ORMs, so the framework choice shouldn't change the database choice.
Why Lakebase answers all five
The answers come from one design decision. A traditional Postgres server keeps its write-ahead log and data files on its own disk, so the machine and the data are inseparable. Lakebase hands the log to SafeKeeper and the data files to PageServer, two independent cloud services, which leaves compute stateless. As Reynold Xin's LTAP engineering blog puts it, compute then "can be started, stopped, and replicated freely, because it no longer owns the data." Branching becomes cheap for the same reason. And because the data is stored on object storage in an open format, it sits on the lakehouse's own foundation. That is the starting point for LTAP, an architecture whose capabilities Databricks is still developing and expanding.
How to set it up
- Create a Lakebase project. Each new project starts with a production branch for your application data.
- Build the agent. Use Genie Agents for a no-code agent. For an agent in code, the Agent Bricks CLI (Beta) quickstart can scaffold a project with managed sessions and memory (also Beta) already set up.
- Branch risky work. Give each experiment a short-lived branch that deletes itself; until then, storage is billed only for what changes on it.
- Sync what the agent reads. Create synced tables for the lakehouse tables it needs, and query them with the same Postgres connection it uses for its own writes.
- Register the database in Unity Catalog for permissions, lineage and audit logs alongside your lakehouse data.
- Add connection retry logic, which Databricks recommends for the brief reactivation after scale to zero.
Docs: synced tables and branches.
FAQs
Do I also need a vector database?
Not necessarily. Lakebase supports pgvector, and Lakebase Search, which is generally available, adds vector, keyword and hybrid search inside Postgres.
Can Lakebase hold my agent's memory?
Yes. Databricks' managed agent memory, the recommended path for new agents, stores durable facts, preferences and past decisions in Lakebase and retrieves them by semantic search; it is in Beta. For the agent's own records, pgvector or Lakebase Search keeps embeddings beside the rows they describe.
What if my agent only answers questions about data?
A Genie Agent answers natural-language questions over datasets registered in Unity Catalog. Once your agent also keeps state or writes records, that state belongs in Lakebase.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.