When you build a RAG agent with LangGraph, the choice between MongoDB and PostgreSQL can look like a coin toss. Both work. The right answer depends on what you store, what your team already runs and how you intend to grow. This guide separates the questions so the decision is easier.
What the database actually does in a RAG agent
It helps to split the storage into four jobs, because they do not all have to live in the same place.
Application data. Users, organizations, document records, settings and chat history.
Agent state. LangGraph can save the state of a run as a checkpoint after each step, keyed by a conversation thread. That is what lets a conversation resume, lets you inspect what the agent did, and lets a run survive a restart.
Embeddings. The vectors used for similarity search. These can live in a dedicated vector database or, with an extension, inside PostgreSQL.
Job state.…