Blog

The best database for AI agents (2027)

Which database fits your AI agent transactions, checkpoints, and vector retrieval? Decide between PostgreSQL, pgvector, and Aerospike. Read the full guide.

blog-color-space-navy-pattern-layers
Alex Patino Alexander Patino Solutions Content Leader Published November 18, 2026 Read time 50 min read

AI agents read and write more kinds of data than a typical application. One support agent might load a conversation history, run a semantic search over help articles, update a customer record, save a checkpoint to resume a failed run, and log each tool call for audit. Each of those operations has its own durability, latency, availability, and query requirements.

That breadth of requirements is why the database decision for agentic AI rarely ends with one product. Many production stacks pair a transactional database for records and state with a retrieval layer for embeddings, and sometimes add a cache or an analytics store. For most teams, the question is whether the database they already run also covers retrieval.

Answering that question before comparing vector databases keeps the stack as small as the workload allows. Every additional store adds a synchronization path, more work, and more money, so the database you’re already using is often the cheapest one to extend, if you can.

Quick answer: What is the best database for AI agents?

For many teams, the best database for AI agents is the transactional database that already holds the agent's authoritative state, extended with vector search when the retrieval workload fits. PostgreSQL with the pgvector[1] extension holds agent state, business records, and embeddings in one transactional system. A dedicated vector database becomes the better choice when filtered search accuracy, vector volume, or retrieval latency exceeds what pgvector delivers on your own data. For agents that make many database calls per task, the slowest of those calls sets the response time, so measure tail latency across a full task's calls before deciding.

Agent situation

Default database choice

Switch when

You already run PostgreSQL and need semantic search over your own data

PostgreSQL with pgvector

Filtered queries still return too few rows after tuning, the vector index no longer fits in memory, or tail latency misses its target at the agent's real fan-out

The agent updates business records such as orders, inventory, or permissions

A relational database with ACID transactions

Write volume or multi-region requirements exceed one primary; evaluate distributed SQL such as CockroachDB or TiDB

The agent fans out many lookups per task at high concurrency with strict p99 and p99.9 targets

A distributed key-value database that keeps its index in memory, such as Aerospike or Couchbase, tested for tail latency at your fan-out

Transactions must span namespaces or run longer than 120 seconds, or most queries join many entities; evaluate a relational or distributed SQL database

Retrieval over millions of documents with heavy metadata filtering is the main workload

A dedicated vector database, such as Milvus, Pinecone, Qdrant, or Weaviate

Embeddings and source records must stay consistent in one transaction, or the sync process falls behind

Session context, caching, and short-lived agent state

Redis or another in-memory store

Data must survive a restart without loss, or a write must span keys in different Redis cluster hash slots

Records are documents and change structure often

Azure Cosmos DB or MongoDB Atlas with vector search

Most queries depend on joins across many entities

Historical analysis across agent output and enterprise data

A data warehouse or lakehouse, such as Databricks or Snowflake

The agent needs frequent, low-latency transactional writes

A local or single-user agent

Chroma, or SQLite with a vector extension such as sqlite-vec

Several users or processes need to write at the same time

Here are three rules of thumb:

  • Store any state that an agent changes and a person later relies on, such as an order, a ticket status, or a permission, in a transactional database. Also check what each transaction covers: one row, one partition or shard, or the whole cluster.

  • Use a dedicated vector database when retrieval is the main workload and filtered vector search has to stay accurate across a large corpus.

  • Keep embeddings in the existing database when the corpus is modest, and most retrievals also need relational filters or joins.

Measure each switch condition in the table on a staging copy of your data. That lets query results from your own workload decide which row applies.

What does an AI agent store?

An AI agent's data falls into five categories of state: durable records, run checkpoints, semantic recall, relationships between facts, and telemetry. Only one of those five, semantic recall, requires a semantic retrieval mechanism, and vector search is one common implementation. The other four are familiar database workloads with well-understood storage choices.

Type of agent state

What it holds

Default store

Use a different store when

Risk if stored in the wrong place

Durable records

Users, permissions, configuration, orders, tickets, task status and other structured data, plus pointers to files such as reports and images kept in object storage

A relational database with ACID transactions

Records are documents (use a document database) or writes outgrow one primary (use distributed SQL)

Partial updates leave business data inconsistent

Run checkpoints

A snapshot of an agent run so it  resumes after an interruption or failure

A table in the same transactional database; SQLite for local development

Runs are short-lived and need to survive only a few minutes (use in-memory store)

A restart loses in-progress work

Semantic recall

Embeddings of documents, past conversations, and decisions, queried by meaning

Vector search in the existing database when the corpus and retrieval workload fit

Retrieval is the main workload and the corpus is large or heavily filtered (use a dedicated vector database)

Retrieval returns wrong or incomplete context

Relationships and changing facts

How entities connect, and which fact was true at which time

Relational tables with foreign keys and validity timestamps

Multi-hop traversal is the core query pattern (use graph databases)

The agent acts on a fact that has since changed

Telemetry

Prompts, responses, tool calls, and latencies for every step

An analytics store or log pipeline, separate from transactional data

Volume is small enough that a separate table is simpler

Trace writes compete with the queries the agent depends on

Run checkpoints need durable storage from the first production deployment, because the in-memory options that agent frameworks ship for development lose every in-progress run when the process restarts. LangGraph’s in-memory checkpointer keeps checkpoints in RAM, and its persistence documentation[2] recommends a persistent checkpointer such as PostgresSaver for production. Google’s ADK documentation[3] says InMemorySessionService loses its state on restart. The LangGraph page also separates checkpointers, which save one thread’s graph state for resuming and fault tolerance, from stores, which hold user preferences and facts across threads. It notes that checkpoints accumulate over long conversations and can increase latency and storage costs.

Checkpoints can also be the largest write workload on an agent platform, because every step of every run writes one. A platform with 1,000 concurrent runs that each complete a step every two seconds writes 500 checkpoints per second. At an assumed 20 KB per checkpoint, enough for a serialized state that holds recent messages and tool results, that is about 10 MB of writes per second of system overhead, before any business record changes. Substitute your own run count, step rate, and checkpoint size, then size the checkpoint store for that write rate and a retention policy.

Telemetry is different from the other four types. Trace data is written on every step, rarely updated, and mostly queried in aggregate, which works for an analytics store better than with relational data. Keeping traces separate prevents logging volume from slowing the reads and writes an agent needs to finish a task.

Sorting an agent's data into these five types before choosing a product shows how many stores the workload needs. The answer is often fewer than five, because one transactional database can hold records, checkpoints, and a modest amount of vector data together.

Do AI agents need a memory layer?

Many AI agents need less persistent agent memory than a dedicated memory layer provides. Instructions that apply to every run belong in versioned documentation, facts about a specific user or account belong in database rows, and only knowledge too large to load in full needs semantic retrieval.

Adding context to an agent has a measurable cost. In a study of coding agents presented at ICLR 2026[4], researchers at ETH Zurich and LogicStar.ai found that repository context files such as AGENTS.md produced no improvement in task success rates while increasing inference cost by more than 20%. Traces showed more file exploration and more testing on each task when context files were present, and the authors recommended that context files describe only minimal requirements. The study covered context files only, so it supports a narrow point: Added context has a price, and a memory layer should be measured for the task-success gain it delivers against that price.

Stale facts are another issue. A similarity score measures how close two pieces of text are in meaning but doesn’t say which of two facts is current. Retrieval pipelines handle this by storing a timestamp or version in metadata and filtering or re-ranking on it, but vector search doesn’t require that. For example, if a user changed a shipping preference last week and the pipeline skips it, embeddings of the old and new preference both score as relevant. A preference stored as a database row and updated in place avoids the problem.

Four kinds of agent knowledge cover most of what a memory layer would store, and only one of them needs semantic retrieval:

Type of agent knowledge

Example

Where it belongs

Why it belongs there

Standing instructions

Build commands, style rules, escalation policy

Versioned documentation or an instructions file

Changes are reviewed and apply to every run

Entity facts

A customer's preferred units or contract tier

A database row with an updated timestamp

Exact lookup, and new values overwrite old ones

In-progress task state

The steps completed in the current run

A checkpoint table

Needed only to resume the current run

Large reference corpus

Five years of resolved support tickets

A vector index with metadata filters

Too large to load, useful only in part

Looking at this information before adopting a memory product shows how much of the agent's knowledge needs vector search. For many agents, the answer is the reference corpus alone, which narrows the database decision to one question about retrieval.

Do you need a vector database, or will PostgreSQL with pgvector do?

Most teams that already run PostgreSQL can start with pgvector and move to a dedicated vector database only when a measured limit appears. pgvector[1] is an open-source extension that adds vector types, exact and approximate nearest-neighbor search, and HNSW and IVFFlat indexes to PostgreSQL. Embeddings stored with pgvector keep the same ACID guarantees, joins, and point-in-time recovery as the rest of the database.

Keeping vector data beside relational data removes the sync job between two databases. An agent can filter by account, join to a permissions table, and rank by similarity in one SQL query, inside one transaction. A separate vector database needs its own copy of every filter field and a process that keeps that copy current. 

One database also keeps retrieval metadata and authoritative state transactionally consistent, because a permission change and the documents it governs get updated in the same system, even though the vector index itself remains approximate. The transaction makes the record update and the vector write atomic once the embedding exists; generating that embedding through an external model remains an asynchronous step that needs its own retry and consistency strategy, such as an outbox table. 

Queries pay a similar cost: Each retrieval embeds the agent's question through a model call before the database lookup runs, so latency budgets need separate targets for the embedding call and the database read.

How to tell whether PostgreSQL can handle it

These five checks, run on a staging copy of production data, help you figure that out for most workloads:

  1. Confirm the database supports vectors. pgvector supports PostgreSQL 13 and later. If the agent's records are stored in another relational database, such as MySQL or SQL Server, check whether your version offers a native vector type before adding a second system.

  2. Estimate the vector working set. The pgvector reference[5] gives storage per vector as 4 × dimensions + 8 bytes, or 2 × dimensions + 8 bytes for the half-precision halfvec type. One million 1,536-dimension embeddings take about 6.2 GB as vector and about 3.1 GB as halfvec, before index overhead. Compare that with the memory on the instance you plan to run.

  3. Measure filter selectivity. Find the share of rows a typical retrieval filter matches, such as one tenant's documents. Approximate indexes can miss matching records when filters select few rows, so test those filters separately.

  4. Measure recall and latency together. pgvector's documentation recommends monitoring recall by comparing approximate results with exact search on the same query. Measure recall and p99 latency for the filter selectivity identified in step 3.

  5. Measure write load. Agents that write memories on every step insert into the vector index continuously. Test inserts and searches at the same time, at the expected peak rate.

If recall, latency, and write throughput meet their targets, pgvector is enough for the workload. If one misses, try applying the following fixes before planning a migration.

Fixes to try inside PostgreSQL first

The pgvector documentation lists several ways to shrink the working set or scale out without leaving PostgreSQL:

  • Half-precision storage and indexing with halfvec roughly halve vector storage and raise the HNSW index limit from 2,000 to 4,000 dimensions.

  • Binary quantization with re-ranking builds a smaller index on bit vectors, then re-orders candidates by the full vectors for better recall.

  • Partial indexes and list partitioning give each tenant or category its own index, which improves filtered recall.

  • Read replicas move retrieval traffic off the primary. PostgreSQL replicas are asynchronous by default, so retrieval on a replica can lag the primary and give up the same-query consistency between permissions and documents; reserve replicas for retrieval that can handle that lag. Sharding tools such as Citus spread vectors across nodes.

When is it time to add a dedicated vector database?

A dedicated vector database is the better choice when one of these conditions holds after the fixes above:

  • Filtered recall stays below target even with iterative scans and per-tenant partitions.

  • The vector index outgrows the largest instance you are willing to run, and latency misses its target as a result.

  • Retrieval load slows transactional queries even after it moves to read replicas.

  • Running sharded PostgreSQL for vectors costs more engineering time than a managed vector service would.

PostgreSQL Version 0.8.0 changed filtered search by adding iterative index scans, so measurements taken on earlier versions don’t fit the way it works now. Testing the current release on your own data gives a more reliable answer.

Running the five checks against your own queries helps you decide whether you need a separate vector database. If your system passes, you avoid the cost and complexity of a second system and a data-sync pipeline. If it fails, you know which limitations to address when evaluating dedicated vector databases. 

When does pgvector break in production?

The pgvector documentation describes one production failure in detail: a filtered query that returns fewer rows than requested. Index builds that use up server memory and heavy concurrent inserts are two further limits. All three have documented fixes inside PostgreSQL, and each fix trades some latency or memory for completeness.

Why filtered vector queries return fewer rows than LIMIT

A multi-tenant agent typically retrieves context with a query like this, where 42 stands in for a tenant ID:

SELECT id, title
FROM documents
WHERE tenant_id = 42
ORDER BY embedding <=> $1
LIMIT 10;

With an HNSW index, PostgreSQL applies the WHERE filter after the index selects its candidates. The pgvector filtering documentation[6] shows the effect: with the default hnsw.ef_search value of 40, a filter that matches 10% of rows leaves about four matching candidates on average. The query does not return an error; it simply returns fewer rows.

Small tenants can be affected even more. If a tenant owns 1% of the rows, only 0.4 of the 40 candidates will match on average. Many queries may return no results, even when relevant documents exist. More generally, the expected number of matches is 40 multiplied by the percentage of rows that pass the filter. A query with LIMIT 10 will return fewer than 10 rows on average if the filter matches less than 25% of rows.

These estimates assume each tenant’s documents are evenly distributed throughout the vector space. In practice, documents often cluster together. Queries near a tenant’s cluster may return more matches, while queries farther away may return fewer. This makes recall difficult to predict from one test.

How to fix filtered recall in pgvector

The first adjustment to try is raising hnsw.ef_search, which widens the candidate list for every query. The pgvector query options[7] note that a higher value improves recall at the cost of speed. At 100, a filter that matches 10% of rows would be expected to yield about 10 qualifying candidates on average under the same simplifying assumption, which is roughly enough for LIMIT 10. A tenant that owns 1% of rows would need a value near 1,000 for the same result, and one setting applies to every query, so a value large enough for the smallest tenant slows retrieval for all the others.

pgvector 0.8.0 added iterative index scans[8], which keep scanning the index until enough rows pass the filter or a scan limit is reached:

BEGIN;
SET LOCAL hnsw.iterative_scan = relaxed_order;
SET LOCAL hnsw.max_scan_tuples = 40000;
SELECT id, title FROM documents
WHERE tenant_id = 42
ORDER BY embedding <=> $1 LIMIT 10;
COMMIT;

The relaxed_order mode returns results slightly out of distance order in exchange for better recall, while strict_order keeps exact ordering. The scan stops at hnsw.max_scan_tuples, which defaults to 20,000 tuples. The example above doubles that cap to 40,000 so a small tenant’s rows have more room to turn up. A higher cap recovers more rows, but every extra tuple the scan visits adds latency.

Tenant count decides which structural fix applies. With hundreds or thousands of tenants, a partition or index per tenant becomes more work on its own, and iterative scans with a tuned scan budget are the better fit. With a manageable number of tenants or categories, the structural fix is to give each one its own partition or index. pgvector's multitenancy guidance[9] notes that a shared approximate index lets one tenant's vectors affect recall and speed for other tenants, and recommends list partitioning or separate tables:

CREATE TABLE documents (
  tenant_id int,
  title text,
  embedding vector(1536)
) PARTITION BY LIST (tenant_id);

For a filter with only a few distinct values, a partial index does the same job. Create one index per value; this one covers tenant 42: CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops) WHERE (tenant_id = 42). Each partition or partial index searches only the rows the filter allows, so cross-tenant post-filtering goes away, although approximate search still gives up some recall for speed.

Index builds and write-heavy agents

HNSW indexes build faster when the graph fits in maintenance_work_mem, and pgvector's index build guidance[10] warns against setting that value so high that it uses up server memory. Building on a production primary therefore needs a memory budget and a concurrent build:

SET maintenance_work_mem = '8GB';
SET max_parallel_maintenance_workers = 7;
CREATE INDEX CONCURRENTLY ON documents
USING hnsw (embedding vector_cosine_ops);

CREATE INDEX CONCURRENTLY allows writes to continue during most of the build. The build still takes longer than a standard one, scans the table more than once, and uses CPU and I/O, so it needs capacity planning on a production primary. Agents that write memories on every step add a second cost: a higher ef_construction value improves recall at the expense of build time and insert speed. Testing inserts and filtered searches at the same time, at peak write rate, shows whether one index can handle both.

The 8 GB in this example is a total for the build. PostgreSQL applies maintenance_work_mem to the entire utility command[11], regardless of the number of parallel workers, although parallel builds still use more CPU and I/O. Leave room for shared_buffers and active connections when choosing the value on a production primary.

Checking recall in production

Recall loss does not generate an error, so it needs its own check. pgvector suggests comparing approximate results with exact search for the same query, and EXPLAIN (ANALYZE, BUFFERS) confirms whether the planner used the vector index at all:

-- Exact search: ordering by an expression bypasses the HNSW index
SELECT id FROM documents
WHERE tenant_id = 42
ORDER BY 1 - (embedding <=> $1) DESC
LIMIT 10;

pgvector's troubleshooting notes[12] state that the HNSW index is used only when results are ordered by a distance operator in ascending order. Ordering by an expression therefore keeps the HNSW index out of the nearest-neighbor ordering, and PostgreSQL may still use a conventional index on tenant_id to narrow the exact search. The exact query reads every row for that tenant, so run the comparison on a replica or staging copy.

Running this comparison on a sample of agent queries each week gives a measured baseline for query optimization for retrieval. For agents, missing rows carry more risk than on a search page: A response generated from four documents instead of ten draws on incomplete context without letting anyone know. 

How should you evaluate a database for AI agents?

Four criteria carry the most weight when evaluating a database for AI agents: transaction scope, filtered retrieval quality, tail latency under concurrency, and availability during failures. Ten additional criteria complete the evaluation. Test each one against your own data.

Core criteria

Evaluation criterion

Question to ask

How to test it

Transaction scope

Can related writes commit together or not at all, and across what scope?

Run a multi-record update across partitions and halt the client mid-transaction.

Filtered retrieval quality

Does recall hold at your real filter selectivity?

Compare approximate results with exact search for filtered queries.

Tail latency under concurrency

What are p99 and p99.9 latency across all the calls in one task?

Replay a full task's database calls at peak concurrency and record the slowest call per task.

Availability during failures

What happens when a node, zone, or region fails mid-task?

Halt a node during a load test and measure errors, failover time, and recovery of in-flight writes.

Additional criteria

Evaluation criterion

Question to ask

How to test it

State coverage

Which of the five categories of agent state can it hold?

Map each state type to a table, collection, or index in the candidate.

Retrieval freshness

How quickly does a change to a source record become visible to retrieval?

Update a record, then measure the time until retrieval returns the new version.

Recovery semantics

What happens to in-progress agent state when a process fails?

Halt an agent mid-run and retry a tool call; check checkpoints, duplicate actions, and idempotency.

Scaling the model

How does it handle growth in concurrent requests as well as data size?

Forecast requests per task, multiplied by tasks per second, 12 months out.

Write throughput under search

Do inserts slow concurrent queries?

Load-test inserts, checkpoint writes, and filtered searches together at peak rate.

Ecosystem

How well does it integrate with your agent framework, SDK language, and model context protocol (MCP) tools?

Build one end-to-end retrieval and write path.

Work

Who handles backups, upgrades, and failover?

List the runbooks your team would be responsible for.

Security

Does it support scoped roles, encryption, and audit logs?

Create a least-privilege role for the agent and test what it can access.

Cost predictability

How does the bill change with reads, writes, and storage?

Price the current workload and 3x that workload.

Portability and exit cost

How do you export vectors, metadata, and schema?

Export a sample collection and reload it elsewhere.

Transaction scope and filtered retrieval are easiest to see in an example. Consider an order-management agent that reserves stock and updates the customer record in one step. If the database cannot commit both writes together, a failure between them leaves stock reserved for an order the customer record never shows. Filtered retrieval matters in the same way for the read path, because most agent queries are scoped to one user, account, or tenant.

Retrieval freshness and recovery semantics matter more for agents than for search applications. If a customer's permissions change while an agent is mid-task, retrieval that lags the authoritative record lets the agent act on context it should no longer see. Agents also run for minutes or hours and take several actions, so a crash or failover needs durable checkpoints and idempotent tools that keep a retried step from repeating an action.

For portability, the full exit cost includes extraction, transformation, egress, a dual-write or cutover period, reindexing in the new system, and validation. Make sure you consider that cost before deciding. 

Label each claim you collect in one of three ways: measured independently, reported by the vendor, or inferred from architecture.

Scoring every candidate on the same fourteen criteria, with the evidence label beside each score, gives a comparison that reviewers can check. It also shows which criteria lack evidence from your own workload.

Why do tail latency and availability decide whether an agent is usable?

An agent's response time is set by the slowest database call behind it, and its availability by every store it depends on. Both effects grow with the number of calls per task, so an agent that makes fifty lookups before answering needs different database properties from one that makes two.

How fan-out turns rare slow calls into common slow responses

Tail latency is the latency of the slowest share of requests, usually reported as p99 or p99.9. Fan-out, the number of database calls an agent waits on to finish one task, turns rare slow calls into common slow responses. If each database call has a 1% chance of exceeding its p99 latency, a task that waits on 50 independent calls has about a 39% chance that at least one of them does, because 1 − 0.99^50 ≈ 0.39. Even at the p99.9 level, the same task still has about a 5% chance of hitting a slow call.

The slowest call sets the response time a user sees, so average latency is the wrong target for agent databases. The useful measurement is p99 and p99.9 for a full task's set of database calls, replayed at the same concurrency the platform will run.

Concurrency grows faster than data for agent platforms. Request rate equals requests per task multiplied by tasks per second, and both factors grow as agents take on more work. A platform can double its request rate without adding a row, so capacity plans for agent databases start from requests per second.

How each additional store affects availability

An agent that synchronously depends on three stores to answer works only when all three are available. If each store offers 99.9% availability and failures are independent, the combination offers about 99.7%, because 0.999^3 ≈ 0.997. That is roughly 26 hours of expected downtime a year instead of about 9. Independence is a simplifying assumption, and shared infrastructure makes outcomes better or worse, but the point is the same: Every store added to the critical path adds a way for the agent to fail.

Availability also depends on behavior during failure. The questions to answer for each candidate are how long failover takes, whether writes acknowledged before a node failure survive it, and whether the database keeps serving in another zone or region. Measuring p99.9 at real fan-out and testing a node failure under load show whether an agent will work in production. 

How do the main databases for AI agents compare?

The databases teams evaluate for AI agents span relational, distributed SQL, distributed key-value, document, in-memory, vector, and embedded designs, listed here in alphabetical order. Product category is a good way to start narrowing your options, but how much a transaction covers varies a lot from product to product. 

Database

Category

Best for

Transaction scope

Main limitation for agents

Aerospike

Distributed key-value and document, with graph through Aerospike Graph

High-concurrency agent platforms with strict tail-latency targets

Multi-record within one namespace; strong consistency mode required; 10-second default deadline, 120 seconds maximum (Database 8.0 and later)

No vector search; semantic recall needs a separate retrieval layer

Azure Cosmos DB for NoSQL

Document

Document data on Microsoft Azure

Within one logical partition

Queries across many entities are less natural than SQL

Chroma

Vector

Prototypes and local development

Not a transactional store

Default client runs in memory

CockroachDB

Distributed SQL, PostgreSQL wire-compatible

Multi-region transactional agents

Cluster-wide, serializable

Per the current documentation, backfilling a vector index on an existing table blocks writes

Databricks Lakebase

Managed PostgreSQL in a data platform

Agents that need lakehouse data at low latency

Within one PostgreSQL database

Designed for teams on Databricks

Milvus

Vector

Very large embedding collections

Not a transactional store

More components to operate

MongoDB Atlas

Document

Document  records with embeddings

Multi-document, including across shards

Fewer join options than SQL

Neon

Serverless PostgreSQL

Agents that create and branch databases

Within one PostgreSQL database

Same pgvector filtering behavior as PostgreSQL

Pinecone

Managed vector database

Managed retrieval at scale

Not a transactional store

Plan minimums; separate system to sync

PostgreSQL with pgvector

Relational

Teams already on PostgreSQL

Within one PostgreSQL instance; replicas asynchronous by default

Filtered HNSW queries need tuning

Qdrant

Vector

Heavily filtered retrieval

Not a transactional store

Separate system to sync

Redis

In-memory

Session state, caching, fast lookups

Keys in one hash slot when clustered

Memory cost; persistence settings decide what a restart loses

Snowflake Cortex Search

Search service in a data platform

Retrieval over data already in Snowflake

Not used for agent write paths

Suits data already in Snowflake

SQLite with sqlite-vec

Embedded relational

Local and single-user agents

Single file, one writer at a time

One writer at a time

TiDB

Distributed SQL, MySQL-compatible

Transactional agents that outgrow one primary

Cluster-wide

Vector indexes require TiFlash replicas

Weaviate

Vector

Hybrid keyword and vector retrieval

Not a transactional store

Separate system to sync

Two properties separate these databases for agents: transaction scope and tail latency under concurrency. 

  • Transaction scope appears in the table, and it varies from one hash slot or one partition to the whole cluster. Relational, distributed SQL, and document databases update records and embeddings in one transaction once the embedding has been generated, while dedicated vector databases need a sync process. 

  • Tail latency depends on architecture, hardware, data layout, and request mix, so it has to be measured at the agent's real fan-out and concurrency.

Reading the table by category first narrows a vendor list to two or three candidates. Comparing the shortlisted candidates on best fit, strengths, and limitations often makes the choice within each category.

Which database is best for each type of AI agent?

Each database below fits a specific agent workload, and each has a limitation that rules it out for others. The profiles appear in alphabetical order and use the same four labels so they can be compared: best for, strengths, limitations, and when to skip it.

Aerospike

  • Best for: Agent platforms with high concurrent request rates and many lookups per task, where tail latency and availability set the requirements for durable records, checkpoints, and session state

  • Strengths: Aerospike's default storage configuration, its patented Hybrid Memory Architecture, keeps the primary index in memory and records data on SSDs; in-memory and all-flash configurations are also available. Aerospike Database 8.0 added distributed ACID transactions that are strictly serializable across multiple records in a namespace, built on a strong consistency mode that Jepsen tested in 2018[13] for single-record operations. On latency, a benchmark by McKnight Consulting Group, published by Aerospike, recorded sub-millisecond p99 latency for Aerospike on YCSB workloads of 1 TB to 10 TB at 70/30 and 100/0 read/write ratios (benchmark-backed, single operations rather than multi-call agent tasks). Aerospike's documentation includes agent memory tutorials for LangGraph and Google's ADK.

  • Limitations: As of October 2026, Aerospike does not offer vector search; the Aerospike Vector Search client was archived in June 2025[14], so semantic recall needs a separate retrieval layer. Transactions require a strong-consistency namespace and must finish within a deadline of 10 seconds by default and 120 seconds at most, which fits one agent step rather than a whole run. Queries that join many entities belong in application code or another system.

  • Skip it if: One agent with modest request rates works on data that is already stored in PostgreSQL.

Azure Cosmos DB for NoSQL

  • Best for: Teams on Microsoft Azure where agent data is already in documents 

  • Strengths: Azure Cosmos DB for NoSQL[15] stores embeddings alongside documents, offers DiskANN, flat and quantized flat vector index types, and combines vector search with its standard WHERE filters.

  • Limitations: Relational queries across many entities don’t work as well as in SQL, and vector configuration is tied to Cosmos DB's container and vector policy model.

  • Skip it if: Your agent's data and operations are stored outside Microsoft Azure.

Chroma

  • Best for: Prototypes and local development of retrieval-augmented agents

  • Strengths: Chroma[16] is Apache 2.0 licensed, runs in memory for prototyping, and also supports a client-server mode.

  • Limitations: Production deployments generally use Chroma's client-server mode or a managed service; the default in-process client is intended for prototyping.

  • Skip it if: You are deploying a multi-tenant agent to production.

CockroachDB

  • Best for: Transactional agents that write in several regions

  • Strengths: CockroachDB v25.2 introduced vector indexes that group vectors into partitions using k-means clustering. The CockroachDB vector index documentation[17] shows indexes prefixed with columns, such as customer_id, which scopes each search to one tenant.

  • Limitations: Vector indexing was introduced as a Preview feature in v25.2. As of November 2026, CockroachDB’s documentation (v26.4) still says the database blocks table writes while a new vector index backfills existing rows, unlike its general online schema changes, and it calls the behavior a known limitation.

  • Skip it if: Your agents run in one region and fit on one primary.

Databricks Lakebase

  • Best for: Agents on Databricks that need transactional writes plus low-latency access to lakehouse data

  • Strengths: Lakebase is managed PostgreSQL inside the Databricks platform, with autoscaling compute, scale-to-zero, branching, and instant restore. Lakebase synced tables[18] copy Unity Catalog tables into PostgreSQL so applications can query enterprise data with full ACID transactions, which keeps agent state close to the data used for analytics and machine learning on the same AI platform.

  • Limitations: Lakebase is designed for organizations already on Databricks.

  • Skip it if: Your data and governance are stored outside Databricks.

Milvus

  • Best for: Very large embedding collections that need a choice of index type

  • Strengths: Milvus supports HNSW, IVF variants, DiskANN, SCANN, and GPU index types, as listed in the Zilliz index type reference[19]. Zilliz Cloud offers Milvus as a managed service.

  • Limitations: The distributed deployment has more components to run than a single-node database.

  • Skip it if: Your collection fits comfortably on one node.

MongoDB Atlas

  • Best for: Records that are documents and change structure often

  • Strengths: MongoDB Atlas is a NoSQL database whose $vectorSearch stage[20] pre-filters documents on indexed fields before similarity scoring. Because filtering happens before scoring, the post-filtering behavior of pgvector's HNSW index does not map onto MongoDB, although recall on selective filters still needs to be measured.

  • Limitations: Every field used in a vector search filter must be declared as a filter field in the index definition. Joins across collections are narrower than SQL joins.

  • Skip it if: Your agent's data is relational, with many entities joined on every query.

Neon

  • Best for: Agents that create databases on demand or need isolated copies of data for testing

  • Strengths: Neon is serverless PostgreSQL with separate processing and storage, and its database code is open source under the Apache 2.0 license. When Databricks announced an agreement to acquire Neon in May 2025[21], it cited fast provisioning and database branching as the capabilities that suit AI agents. Neon is now part of the Databricks platform[22].

  • Limitations: Vector search runs on pgvector, so Neon inherits the same filtered-query behavior as any PostgreSQL database.

  • Skip it if: Your agents run against one long-lived database and never need branches.

Pinecone

  • Best for: Teams that want managed retrieval without running vector infrastructure

  • Strengths: Pinecone is a fully managed, serverless vector database with usage-based billing.

  • Limitations: Paid plans carry monthly minimums and per-query read units that scale with namespace size. Pinecone also sits outside the transactional database, so source records and vectors need a sync process.

  • Skip it if: Your corpus is small enough for pgvector or your usage stays well below the monthly minimum.

PostgreSQL with pgvector

  • Best for: Teams that already run PostgreSQL and want vector search beside their relational data

  • Strengths: pgvector stores embeddings in ordinary PostgreSQL tables with ACID compliance, joins, and point-in-time recovery, according to the pgvector documentation[1]. PostgreSQL full-text search combined with pgvector supports hybrid retrieval through Reciprocal Rank Fusion.

  • Limitations: Filtered HNSW queries need a higher ef_search, iterative scans, or per-tenant partitions to keep recall. The vector type can be indexed up to 2,000 dimensions, or 4,000 with halfvec, and PostgreSQL scales vertically unless you add replicas or sharding.

  • Skip it if: Retrieval is the main workload and the vector index outgrows the largest instance you are willing to run.

Qdrant

  • Best for: Retrieval with heavy metadata filtering

  • Strengths: Qdrant is open source and attaches JSON payloads to vectors for filtering by keyword, full-text, numeric range, and geolocation, according to the Qdrant repository[23]. Payload indexes inform query planning, and Qdrant reports RAM reductions of up to 97% for some quantization configurations.

  • Limitations: Qdrant is a separate system from the transactional database, so source records and vectors need a sync process, and retrieval can fall behind the authoritative record.

  • Skip it if: Your filters and data are already stored in one relational database.

Redis

  • Best for: Session state, caching, and lookups that need low-latency reads

  • Strengths: Redis 8[24] merged Redis Stack into Redis Open Source, so the Redis Query Engine for vector search, full-text search, and aggregations ships in the core distribution. Redis 8 also added a vector set data type, released in beta, which complements the Query Engine's vector search.

  • Limitations: Redis' primary serving model keeps the working dataset in memory, so storage cost grows with every retained record and embedding. In a Redis cluster, a MULTI/EXEC transaction can only include keys in the same hash slot[25], and how much data a restart loses depends on the persistence settings. Licensing has also changed twice: Redis moved from the BSD license to a dual source-available license for version 7.4 and later in March 2024, as LWN reported[26], and Redis 8 added AGPLv3 as a third option[27].

  • Skip it if: You need a long-term archive of agent history or business records.

  • Best for: Retrieval over data that is already stored in Snowflake

  • Strengths: Snowflake Cortex Search[28] provides hybrid vector and keyword search with reranking over data already in the Snowflake data warehouse, with embedding generation and indexing handled by the service.

  • Limitations: Cortex Search is a retrieval service, so agent state and transactional writes need another store.

  • Skip it if: Your agent's reference data is stored outside Snowflake.

SQLite with sqlite-vec

  • Best for: Local, single-user and on-device agents

  • Strengths: sqlite-vec[29] is a vector search extension for SQLite written in C with no dependencies, designed for applications that keep data on the device.

  • Limitations: SQLite allows only one writer at a time.

  • Skip it if: Several users or processes write to the same agent state.

TiDB

  • Best for: MySQL-compatible transactional workloads that outgrow one primary database

  • Strengths: TiDB adds vector columns and HNSW vector search indexes to a horizontally scalable SQL database, according to the TiDB vector search index documentation[30].

  • Limitations: TiDB vector indexes rely on TiFlash replicas, and the same documentation notes that building vector indexes on TiFlash nodes with encryption at rest enabled is not supported.

  • Skip it if: One PostgreSQL or MySQL primary handles your write volume.

Weaviate

  • Best for: Retrieval that needs keyword matches and semantic matches in one ranked list

  • Strengths: A Weaviate hybrid search[31] runs a vector search and a BM25 keyword search, then combines the results. Weaviate also embeds queries itself through a configured model provider.

  • Limitations: Weaviate is a separate system from the transactional database, so source records and vectors need a sync process, and retrieval can fall behind the authoritative record.

  • Skip it if: Exact-term matching is rare in your queries and pgvector meets your recall target.

Shortlisting one database per category and testing each against the same filtered queries, at the agent's fan-out, shows how each would manage your workload. For many agents, that test comes down to one PostgreSQL-based option, one distributed option, and one dedicated vector database.

Letta, Mem0, and Zep: Which database sits underneath each memory framework?

Memory frameworks extract facts from agent conversations, store them, and retrieve them later, and each one runs on top of one or more databases. Choosing Letta, Mem0, or Zep therefore also chooses a storage stack, and that stack is part of the database decision. The descriptions below reflect each project's documentation as of October 2026.

Memory framework

What it is

Documented storage

How it treats changing facts

Deployment

Letta

An agent runtime that persists the full agent state

PostgreSQL tables, with pgvector for embeddings

The runtime updates memory blocks through tool calls and persists every step

Self-hosted server or managed service

Mem0

A memory layer added to an existing agent

Open source defaults to a local Qdrant vector store and a SQLite history store

Configurable through the chosen vector store; graph features are now performed by the hosted platform

Self-hosted library or hosted platform

Zep

A memory service built on the Graphiti temporal knowledge graph

A knowledge graph, with search built on Neo4j's Lucene implementation

Records when each fact was valid, and marks contradicted facts invalid

Hosted service, with Graphiti available as open source

Letta

Letta's agent documentation[32] states that an agent's state is checkpointed and persisted to the database at each step of its reasoning loop. A Letta deployment walkthrough on the AWS Database Blog[33] adds that Letta keeps memories, tools, and messages in normalized PostgreSQL tables and uses pgvector for embeddings. Adopting Letta means adopting its runtime as well as its storage, which suits teams that want the framework to be responsible for agent state.

Mem0

Mem0's open-source documentation[34] lists a local Qdrant instance as the default vector store and a SQLite database as the default history store, and both can be replaced through configuration. The Mem0 SDK changelog[35] records that graph memory, including its Neo4j, Memgraph, and Kuzu drivers, was removed from the open-source SDK, with graph features moved to the hosted platform API. A team that adopted Mem0 for graph memory on its own infrastructure would need to change its plan after that release.

Zep

The Zep research paper[36] describes Zep as a memory layer powered by Graphiti, a knowledge graph engine that tracks two timelines: when a fact was true and when Zep ingested it. When a new fact contradicts an existing one, Graphiti marks the older fact invalid and keeps it, which preserves history. The paper's search functions use Neo4j's Lucene implementation, so the underlying store is a graph database.

When relationships and time matter

Tracking when a fact was true does not require a graph database. A relational table with valid_from and valid_to columns answers "what was this customer's plan on March 1" with an ordinary SQL query. Graph databases are most useful when the core query follows relationships across several hops, such as finding every open order connected to a supplier whose status changed last week.

The test for any memory framework is the database it brings with it. If that database is one your team already uses, the framework adds a feature to existing infrastructure. If it introduces a new graph or vector database, the framework adds a system to run, secure, and pay for, and that cost should be part of the evaluation.

How much does a database for AI agents cost?

The cost of a database for AI agents depends on how its pricing responds to agent behavior: how often agents query, the size of the searched data is, and how much data must stay in memory. Agents issue retrieval queries on every step of a task, so per-query pricing and memory-bound pricing grow faster for agents than for applications where a person issues each query.

Cost driver

pgvector in an existing PostgreSQL database

Managed serverless vector database

Self-hosted vector database

Fixed monthly cost

None beyond the current instance

Plan minimums apply

Servers and storage, running continuously

Cost per query

Included in instance capacity

Scales with the size of the searched namespace

Included in server capacity

Growth trigger

Vector working set is bigger than instance memory

More queries, larger namespaces, or more writes

Index outgrows server memory or disk

Engineering time

Index tuning on a familiar database

Low infrastructure work

Upgrades, backups, scaling, and on-call

Exit cost

Data stays in PostgreSQL

Records must be read back through the API

Data stays on your servers

How managed vector pricing responds to agents

Pinecone's cost documentation[37], checked in October 2026, shows how serverless pricing interacts with agent workloads. Pricing and plan minimums change, so verify the current figures before making a purchasing decision:

  • Minimums: The Starter plan has no minimum, the Builder plan is a flat $20 a month with usage above its limits blocked, Standard has a $50 monthly minimum, and Enterprise has a $500 minimum. A Standard account that uses $20 in a month is still billed $50.

  • Query cost: A query uses 1 read unit per GB of the namespace it searches, with a minimum of 0.25 read units. The number of results requested does not change the cost.

  • Namespace size: The same documentation sizes 1 million records with 1,536-dimension vectors and 1,000 bytes of metadata at 7.15 GB. Every query against that namespace uses about 7.15 read units.

An agent that runs five retrievals per task across 100,000 tasks a month issues 500,000 queries. Against a 7.15 GB namespace, that is about 3.6 million read units a month. Splitting each tenant into its own namespace lowers the cost of each query, because each one searches only that tenant's data.

How in-database and in-memory costs grow

Vector search inside PostgreSQL has no per-query charge, but it competes for the same memory as the rest of the database. The working-set estimate from the PostgreSQL checks shows whether a corpus pushes an instance to the next memory tier, which is the main cost step for in-database vector search.

In-memory stores, such as Redis, price storage by memory, which is the most expensive storage tier on most infrastructure. That pricing suits short-lived session state and caches with eviction rules. It becomes costly for long-retained agent history and large embedding collections.

Self-hosting vs. managed services

Self-hosting replaces per-query charges with fixed server costs and engineering time. The break-even point depends on three numbers you can estimate in advance: monthly queries multiplied by the per-query rate, the server size that holds your working set in memory, and the hours your team would spend on upgrades, backups, and incidents. Teams whose query volume grows faster than their data size tend to reach that point sooner.

Exit cost

Leaving a managed vector database means reading records back out. Using Pinecone's documented rates, a list call returns up to 100 record IDs for 1 read unit, and a fetch costs 1 read unit per 10 records. Reading back 1 million records therefore takes about 10,000 list calls and 100,000 read units of fetches, plus egress costs for the returned data. Extraction is only one part of the exit cost: transformation, reindexing in the new system, a dual-write or cutover period, and validation add to it.

Pricing every candidate against your expected query volume, namespace size, and exit path shows the full cost before you commit. Running the same estimate at three times today's volume shows which option stays affordable as agents take on more tasks.

How do you give an AI agent database access without risking production?

Give an AI agent the narrowest database access that completes its task: a dedicated role with read access to specific tables, writes only through defined tools, and human approval for high-impact changes. Prompt injection hides instructions in content an agent reads, and database permissions still limit what those instructions can reach.

Some database access tools for agents provide restricted or read-only modes. DBHub[38], an MCP server that connects agents to PostgreSQL, MySQL, SQL Server, and other databases, provides a read-only mode that accepts only statements on its list of read-only SQL keywords, which blocks writes such as INSERT, UPDATE, and DELETE. Read-only modes like this one belong on every connection an agent uses for exploration and retrieval.

Broad built-in roles may seem like a shortcut, but they aren’t. PostgreSQL's predefined pg_read_all_data role[39] grants read access to every table, view, and sequence, which is wider than most agents need. A role scoped to the tables an agent uses limits what a faulty or manipulated query can expose:

CREATE ROLE support_agent LOGIN;
GRANT SELECT ON tickets, kb_articles TO support_agent;
ALTER ROLE support_agent SET default_transaction_read_only = on;
ALTER ROLE support_agent SET statement_timeout = '5s';

The grants are the security boundary in this example. A session can change default_transaction_read_only, so that setting works as a safety default, while the GRANT statements decide what the role can reach. The statement timeout stops a runaway query from holding resources the rest of the application needs.

A production checklist for agent database access:

  • Give each agent its own database role; never share administrator credentials.

  • Grant read access to specific tables or views, and use row-level security when agents serve several tenants.

  • Route writes through tools with fixed operations, such as reserve_stock or create_ticket, each running in one transaction.

  • Enable read-only mode on any MCP tools that run ad hoc SQL.

  • Set a statement timeout on each agent role, and cap result sizes in the tools that run agent queries.

  • Require human approval for refunds, deletions, and other high-impact writes.

  • Log every tool call with its inputs and results in the telemetry store.

  • Test new agent behavior on a database branch or staging copy before production.

Tools that can only do one set thing make a system safer.  A reserve_stock tool that decrements inventory and writes the order line in one transaction can be tested, rate-limited, and audited, whereas raw SQL generated per request cannot. Following the checklist lets a team expand an agent's responsibilities one tool at a time, with each new permission reviewed before it reaches production data.

What do multi-agent systems need from a database?

Multi-agent systems need three things that single-agent applications rarely ask of a database: isolation between each agent's work, high concurrent write volume, and inexpensive ways to try a change and throw it away. Branching, fast rollback, and per-agent or per-tenant partitioning answer those needs.

Evidence of this comes from Neon platform telemetry, and both sources carry caveats. In the release announcing its agreement to acquire Neon[21], Databricks reported that the share of Neon databases created by AI agents had risen from 30% to over 80%. That figure is a buyer describing the company it was acquiring, and it counts databases created, which says nothing about how long those databases ran or how much production load they carried. A UC Berkeley paper presented at CIDR 2026, "Supporting Our AI Overlords: Redesigning Data Systems to be Agent-First"[40], reported that agents on Neon created 20 times more branches and performed 50 times more rollbacks than human users. Both figures come from one platform, so they describe agent behavior on Neon specifically.

The Berkeley authors describe this as agentic speculation: Agents explore many possible solutions, often in parallel, before committing to one. In their case studies[41], success rates in a text-to-SQL case study rose as agents were allowed more attempts, and many of those attempts overlapped with each other. That combination explains the effect on the database. Agents improve results by trying more options, and each attempt creates queries, writes, or branches that a person would not.

The Berkeley authors note that rollbacks are rare in traditional data systems. If agent workloads elsewhere resemble those observed on Neon, rollbacks become routine, and three architectural needs follow:

  • Branching for experiments. Copy-on-write branches, offered by Databricks Lakebase and Neon, let an agent test a change against real data without copying the full database.

  • Isolation by agent or tenant. Partitioned pgvector tables and CockroachDB vector indexes prefixed with a tenant column keep one agent's data and load from affecting another's results.

  • Caching for repeated work. Caching helps only where queries repeat, such as shared reference
    data or retries within one task. Context tied to one user, document, or task is long-tail, so measure the cache hit rate before adding a cache layer.

Shared memory between agents needs an ownership rule. For example, give each agent its own rows or namespace for working notes and promote facts to a shared table only through one reviewed write path. That keeps agents from overwriting each other's conclusions while still letting them read a common record.

Planning for speculation from the start keeps multi-agent costs more predictable. A database chosen only for today's single-agent queries may need branching, partitioning, and caching added under load, when changes are harder to test safely.

How should you read vendor benchmarks for AI agent databases?

Read a vendor benchmark by checking four factors before the headline number: 

  • What it was compared against

  • Which configuration of the competitor was tested

  • What recall or accuracy target was fixed

  • Whether the dataset resembles your workload

Many published benchmarks for vector databases and memory frameworks are run by a vendor whose product is in the comparison.

Check what it was compared against

The Zep research paper[36] reports 94.8% accuracy on the Deep Memory Retrieval benchmark, ahead of MemGPT's 93.4% with the same model. The same table shows that passing the full conversation to the model, with no memory system at all, scored 94.4%. The authors note that each test conversation contains only 60 messages, which fits in current context windows. A benchmark where the no-memory baseline nearly matches the product says little about the product's value.

The same paper's results on LongMemEval, with conversations averaging about 115,000 tokens, show improvement: 71.2% for Zep against 60.2% for full context with GPT-4o, at about a tenth of the latency. Accuracy also fell by 17.7% on single-session-assistant questions, which ask about information the assistant itself gave earlier in a conversation. Reading the per-category table, beyond the headline average, shows where a memory system helps and where it costs accuracy.

Check which configuration was tested

A Timescale benchmark[42] reported that PostgreSQL with pgvector and the pgvectorscale extension delivered 28 times lower p95 latency and 16 times higher throughput than Pinecone's storage-optimized s1 index at 99% recall, on 50 million 768-dimension embeddings. The authors state that they did not test Pinecone's serverless index because queries were rate-limited. The result covers only the pod-based configuration that was tested and PostgreSQL with an additional extension. It also reports p95 latency, which leaves out the slowest 5% of queries, the share an agent waiting on many calls is most likely to hit.

Check who ran the test

AWS reported up to a 5.7x improvement for specific types of queries[43] after upgrading pgvector on its own Aurora service. Vendor-run results like this one can be accurate, but they still reflect workloads and hardware chosen by the party that benefits. Label them as vendor-reported when you cite them internally.

Test on your own workload

A short test plan produces numbers that apply to your agent:

  1. Export a sample of real agent queries, including their filters.

  2. Compute exact results for each query to serve as a baseline.

  3. Fix a recall target, such as 95% of exact results.

  4. Measure p99 latency for each candidate at that recall, at your expected concurrency.

  5. Repeat the test with inserts running at peak write rate.

  6. Price each candidate at the measured throughput.

A benchmark you run yourself produces results measured on your own data, filters, and concurrency.

Which reference stack fits your AI agent?

Many AI agents fit one of four reference stacks, defined by where authoritative state is stored and the size and filtration of the retrieval workload. 

Reference stack

Durable records and checkpoints

Semantic recall

Session state and cache

Telemetry

Choose it when

Local or prototype agent

SQLite

sqlite-vec or Chroma

In process

Local log files

One user, one machine, or an early prototype

Single-product retrieval agent

Existing PostgreSQL

pgvector in the same database

Optional Redis

Separate analytics store or log pipeline

The corpus is modest and every retrieval filters by account or user

Stateful transactional agent

PostgreSQL, or distributed SQL once writes outgrow one primary

pgvector, or a dedicated vector database for a large, heavily filtered corpus

Redis

Separate analytics store

The agent changes orders, inventory, tickets, or permissions

Multi-tenant or multi-agent platform

Distributed SQL, a distributed key-value database such as Aerospike, or branching PostgreSQL such as Databricks Lakebase or Neon

Per-tenant partitions, or a dedicated vector database with per-tenant namespaces

Redis for repeated reads

Data warehouse for analysis across agents

Many tenants or agents write concurrently, and agents create or branch databases

The stacks differ mainly in where retrieval runs. In the first three, vector search stays inside the database that holds authoritative state until a measured limit moves it out, such as filtered recall or tail latency at the agent's fan-out. In the fourth, tenant count and concurrency often justify a dedicated retrieval layer from the start, with freshness between the two systems tested explicitly.

Final decision checklist

Work through these steps in order before committing to a stack:

  1. Classify agent state. Assign each piece of data to durable records, checkpoints, semantic recall, relationships, or telemetry, and estimate the checkpoint write rate.

  2. Separate documentation from memory. Move standing instructions into versioned files and entity facts into keyed rows, leaving only large reference corpora for vector search.

  3. Run the PostgreSQL checks. Measure working-set size, filter selectivity, filtered recall, and write load on a staging copy of production data.

  4. Measure tail latency at real fan-out. Replay a full task's database calls at peak concurrency and record p99 and p99.9 for the slowest call per task.

  5. Score candidates on the 14 criteria. Include retrieval freshness, recovery semantics, and availability, and label every piece of evidence as measured, vendor-reported, or inferred.

  6. Price current and future volume. Estimate cost at today's request rate and at three times that rate, including exit cost.

  7. Set access controls before the first production write. Create a dedicated role, fixed-operation tools, and approval rules for high-impact actions.

  8. Test failure recovery. Kill a database node under load, crash an agent mid-run and retry a tool call, then confirm the agent resumes from its checkpoint without repeating an action.

A team that completes these eight steps can explain its database choice in terms of its own workload measurements. That record also shows which measurement to repeat when the agent's workload changes, so the stack can grow one store at a time.

FAQs

Frequently asked questions about databases for AI agents

AI agents need a database whenever they keep state beyond one request. Business records, run checkpoints, and user preferences all need durable storage. You don’t often encounter a stateless agent that only answers from its prompt.

A vector database covers semantic recall, which is one of five categories of agent state. Records that the agent changes, run checkpoints, and telemetry need transactional or analytical storage, so agents that act on business data also need a relational or document database.

Many teams on PostgreSQL can start with pgvector and add a dedicated vector database only after measuring a limit. The signals to watch are filtered recall that stays low after tuning, a vector index that outgrows instance memory, and retrieval load that slows transactional queries.

With an HNSW index, pgvector applies 'WHERE' filters after the index selects its candidates, so selective filters leave few qualifying rows. The pgvector documentation[8] recommends iterative index scans, available from version 0.8.0, plus partitioning or partial indexes for filters with few distinct values.

Letta is an agent runtime that persists all agent state in PostgreSQL; Mem0 is a memory layer added to an existing agent. Zep is a memory service built on a temporal knowledge graph. Each one brings its own storage, so the choice also determines which databases your team will run.

Use a durable checkpointer such as PostgresSaver in production. LangGraph's persistence documentation[2] notes that the in-memory checkpointer loses all checkpoints when the process restarts and recommends SqliteSaver for local development.

The best database for a retrieval-augmented agent depends on corpus size and filter selectivity. A modest corpus that is always filtered by account fits pgvector alongside relational data, while a large, heavily filtered corpus that is the agent's main workload justifies a dedicated vector database.

Give the agent its own role with read access to specific tables, route writes through fixed-operation tools that each run one transaction, and require human approval for high-impact changes. Grants are the security boundary, and session defaults such as read-only mode add a second layer.

Vector database cost depends on query volume, the size of the searched data, and plan minimums. Managed serverless services charge per query in proportion to namespace size, while in-database vector search uses existing instance capacity; verify current vendor pricing before deciding, because minimums and rates change.

An agent that depends on an unavailable database stops working. Durable checkpoints, idempotent tools, and a tested failover let the agent resume after recovery without repeating actions it already took.

Take the Operational AI assessment

Your AI is only as current as the data beneath it, and when the operating loop falls behind, every decision runs on a version of reality that no longer exists. Find out where your infrastructure stands: take the technical readiness assessment or the business readiness assessment and get a clear picture of whether your data layer is ready for Operational AI.

Footnotes

  1. GitHub, pgvector README:

    https://github.com/pgvector/pgvector

  2. LangChain Docs, LangGraph persistence:

    https://docs.langchain.com/oss/langgraph/persistence

  3. Google Agent Development Kit Docs, session state:

    https://google.github.io/adk-docs/sessions/state

  4. ICLR 2026 (MemAgents Workshop), Evaluating AGENTS.md: Are Repository-Level Context Files Helpful for Coding Agents?:

    https://iclr.cc/virtual/2026/10021235

  5. GitHub, pgvector README, Reference section:

    https://github.com/pgvector/pgvector#reference

  6. GitHub, pgvector README, Filtering section:

    https://github.com/pgvector/pgvector#filtering

  7. GitHub, pgvector README, Query options section:

    https://github.com/pgvector/pgvector#query-options

  8. GitHub, pgvector README, Iterative index scans section:

    https://github.com/pgvector/pgvector#iterative-index-scans

  9. GitHub, pgvector README, Multitenancy section:

    https://github.com/pgvector/pgvector#multitenancy

  10. GitHub, pgvector README, Index build time section:

    https://github.com/pgvector/pgvector#index-build-time

  11. PostgreSQLCO.NF, max_parallel_maintenance_workers parameter:

    https://postgresqlco.nf/doc/en/param/max_parallel_maintenance_workers/

  12. GitHub, pgvector README, “Why isn’t a query using an index?” section:

    https://github.com/pgvector/pgvector#why-isnt-a-query-using-an-index

  13. Jepsen, Aerospike 3.99.0.3 analysis:

    https://jepsen.io/analyses/aerospike-3-99-0-3

  14. PyPI, aerospike-vector-search package:

    https://pypi.org/project/aerospike-vector-search/

  15. Microsoft Learn, Azure Cosmos DB for NoSQL vector search:

    https://learn.microsoft.com/azure/cosmos-db/nosql/vector-search

  16. PyPI, chromadb package:

    https://pypi.org/project/chromadb/

  17. Cockroach Labs Docs (v25.2), vector indexes:

    https://www.cockroachlabs.com/docs/v25.2/vector-indexes

  18. Databricks Docs, sync tables for OLTP projects (AWS):

    https://docs.databricks.com/aws/en/oltp/projects/sync-tables

  19. Zilliz Docs, Java reference, index types:

    https://docs.zilliz.com/reference/java/v1-Misc-IndexType

  20. MongoDB Docs, Atlas Vector Search stage:

    https://mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage

  21. Databricks Blog, Databricks and Neon:

    https://www.databricks.com/blog/databricks-neon

  22. GitHub, Neon repository:

    https://github.com/neondatabase/neon

  23. GitHub, Qdrant repository:

    https://github.com/Qdrant/qdrant

  24. Redis Docs, what’s new in Redis 8.0:

    https://docs.redis.io/docs/latest/develop/whats-new/8-0

  25. Redis Docs, multi-key operations:

    https://redis.io/docs/latest/develop/using-commands/multi-key-operations/

  26. LWN.net, The race to replace Redis (Joe Brockmeier, March 28, 2024):

    https://lwn.net/Articles/966631/

  27. AlternativeTo, Redis goes open source again with the launch of Redis 8 under the AGPLv3 license (May 2025):

    https://alternativeto.net/news/2025/5/redis-goes-open-source-again-with-the-launch-of-redis-8-under-the-agplv3-license

  28. Snowflake Docs, Cortex Search overview:

    https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/cortex-search-overview

  29. Mozilla Builders, sqlite-vec project:

    https://builders.mozilla.org/project/sqlite-vec/

  30. PingCAP Docs, TiDB vector search index:

    https://docs.pingcap.com/tidb/stable/vector-search-index/

  31. Weaviate Docs, Model2Vec embeddings model provider:

    https://docs.weaviate.io/weaviate/model-providers/model2vec/embeddings

  32. Letta Docs, agents overview:

    https://docs.letta.com/guides/agents/overview

  33. AWS Database Blog, how Letta builds production-ready AI agents with Amazon Aurora PostgreSQL:

    https://aws.amazon.com/blogs/database/how-letta-builds-production-ready-ai-agents-with-amazon-aurora-postgresql

  34. Mem0 Docs, open source:

    https://docs.mem0.ai/open-source

  35. Mem0 Docs, SDK changelog:

    https://docs.mem0.ai/changelog/sdk

  36. arXiv, Zep: A Temporal Knowledge Graph Architecture for Agent Memory:

    https://arxiv.org/html/2501.13956v1

  37. Pinecone Docs, understanding cost:

    https://docs.pinecone.io/guides/manage-cost/understanding-cost

  38. npm, @bytebase/dbhub package:

    https://npmjs.com/package/@bytebase/dbhub

  39. PostgreSQL Docs, predefined roles:

    https://postgresql.org/docs/current/predefined-roles.html

  40. CIDR 2026 (VLDB), Supporting Our AI Overlords: Redesigning Data Systems to Be Agent-First:

    https://vldb.org/cidrdb/2026/supporting-our-ai-overlords-redesigning-data-systems-to-be-agent-first.html

  41. arXiv, Supporting Our AI Overlords: Redesigning Data Systems to Be Agent-First:

    https://arxiv.org/html/2509.00997v2

  42. Tiger Data Blog, pgvector vs. Pinecone:

    https://www.tigerdata.com/blog/pgvector-vs-pinecone

  43. AWS Database Blog, supercharging vector search performance and relevance with pgvector 0.8.0 on Amazon Aurora PostgreSQL:

    https://aws.amazon.com/blogs/database/supercharging-vector-search-performance-and-relevance-with-pgvector-0-8-0-on-amazon-aurora-postgresql