Skip to content
Guide

PostgreSQL or MongoDB? The Answer Depends on Access Patterns, Not Data Shape

PostgreSQL is now used by 55.6% of developers. So when is a document database the right answer? Six questions that decide it.

Oğuzhan Gerçek··4 min read
PostgreSQL or MongoDB? The Answer Depends on Access Patterns, Not Data Shape

Short answer: The choice depends on how you access your data more than on its shape. In the 2025 Stack Overflow Developer Survey, PostgreSQL became the most-used database, with 55.6% of developers and 58.2% of professional developers using it. Going from 48.7% to 55.6% in a single year is the largest jump in the survey's history and opens a 15-point gap over second-place MySQL. That has changed the default in the relational-versus-document debate: today you need a reason to move away from PostgreSQL, not a reason to choose it.

This article covers when that reason is real.

Why PostgreSQL became the default

Three things added up.

JSONB removed half the argument. PostgreSQL supports schemaless document storage and indexed queries over those documents. So "we need a flexible schema" is no longer, on its own, a reason for a separate database; relational and document data can live in the same ACID engine.

The extension ecosystem became a product range. PostGIS for geospatial data, TimescaleDB for time series, pgvector for vector search. Each of these was once a reason to buy a separate system.

No license uncertainty. PostgreSQL's permissive license kept it out of the license-change disputes that have hit several open-source databases in recent years.

So when is MongoDB the right answer?

Data being "unstructured" does not, by itself, justify a document database. If at least two of the following three hold, the reason is real:

The read pattern centers on a single document. If the application reads and writes one whole object bound to one identifier on every request, splitting that object across fifteen tables and rejoining it on every read is an unnecessary cost.

The schema genuinely changes, and often. A product catalog where every record carries different fields, and the field set changes monthly, is a typical example. One distinction is critical: no schema in the database does not mean no schema. It has moved into the application, and it has to be written down there.

Horizontal scaling is a requirement, not a preference. If you have genuinely hit the vertical limit of a single node, sharding makes sense. If you have not, you are paying the operational cost of a distributed system early.

The six questions that decide it

    How many entities does one request touch? One means document; many means relational.Where is the transaction boundary? If several entities must stay consistent together, a relational engine gives you that for free.Are the queries known in advance? Unknown and changing queries are where the relational model and SQL are strongest.How large will the data grow, and how will it split? Without a natural partition key, sharding gets hard.Which one can the team operate? The right choice that nobody can run is worse than a second-best choice the team can.Where will reporting and analytics read from? If you are running two engines, decide up front which one feeds reporting.

In a migration the real risk is the cutover, not the copy

In modernization projects, moving the data is usually a solved problem. The plan breaks at a different point: when and how you switch the old system off.

The approach that works is incremental: dual writes first, then a phased move of reads, then the old system going read-only, and only then shutdown. A way back stays open at every step. This needs the same discipline as safe schema changes: versioned migrations, test environment first, a documented rollback in production.

The two things most often missed at cutover are character set and time zone differences, and the "data debt" that has built up in the old system over the years: mandatory fields left empty, inconsistent date formats, duplicate records. These surface only once the new system's constraints take effect.

Where to start

Choosing a database is less a technology preference than an operational commitment: backup, replication, version upgrades and capacity planning define the next five years. We covered how to set recovery targets in how to calculate RPO and RTO, and how to watch replication health in PostgreSQL replication lag.

You can see how Eclit runs this layer on the database platform engineering page.