Should this data live in PostgreSQL or MongoDB? Choosing between relational and NoSQL
For most business applications the right default is a relational database, and the fastest way to shorten the argument is to change the question. It is not which technology is more modern. It is who will read this data, and with what question. Document stores, key-value stores and search engines earn their place when the access pattern is narrow and known. The sentence "we don't know what we'll need later, let's start schemaless" usually gives back in year two whatever it saved in the first six months. Five things decide this: the questions you will ask, which operations must be atomic, the actual shape of the data, the volume two years out, and who gets paged at three in the morning.
The decision starts with your queries, not with the engine
If you read an order by its id and write the whole thing back, both models work. The gap opens with the questions you did not anticipate. "What was the cancellation rate for that dealer group last quarter, and how many of those customers came back within 30 days" touches three entities. In a relational database that is a query. In a document model it is either duplicated data or a join you write by hand in application code.
The practical split: fixed and countable access patterns suit a document model, open-ended questions suit a relational one. In business software the questions are almost always open-ended, because the person who will ask for the report has not thought of it yet. Neither has the product team. That is why "model the data properly and let the questions come later" produces fewer regrets. The bill for data model decisions never arrives as storage cost anyway.
"Schemaless" does not mean there is no schema
A schemaless collection still has a schema. It just is not written down. Two years in, the same collection holds four generations of the same document: in some of them phone is a string, in others an array, in a few it is missing. The schema changes still happen. They just live inside if branches instead of migration files.
MongoDB offers the cure itself. Collection validators arrived in 3.2 and JSON Schema validation in 3.6. If you go with a document store, write the $jsonSchema validator on day one. Writing it six months later turns into a data cleanup project. Flexibility stays flexibility when it has a written rule next to it. Without one it quietly becomes debt.
Measure your transaction needs early
Decrementing stock, updating a balance, issuing an invoice: these have to be all or nothing. MongoDB supports that, and the history is worth knowing. Multi-document ACID transactions became available on replica sets in 4.0 and on sharded clusters in 4.2. A transaction's default runtime limit is 60 seconds, adjustable through transactionLifetimeLimitSeconds.
The more useful signal is MongoDB's own warning. Its production considerations page states that a multi-document transaction costs more than a single document write, and that good schema design is the first line of defense. So the right answer in a document model is not to reach for transactions often. It is to put everything that must stay consistent inside one document, which only works when your business invariant and your document boundary line up. An order and its line items line up. An order, a stock level and a customer account usually do not.
PostgreSQL already covers what most teams want from a document store
Teams often add a second database because they need "flexible fields", not realising they already have them. PostgreSQL's jsonb type shipped with version 9.4 on 18 December 2014 and is searchable through GIN indexes. PostgreSQL 18, released on 25 September 2025, added operators and functions that delete, modify and insert values inside jsonb at specific path locations, and it made GIN index builds parallel, which matters because GIN is what you use for JSON and full-text search.
The pattern that works in practice is hybrid. Fields with constraints, foreign keys and reports behind them stay as real columns. The part that varies by customer or product type goes into jsonb. One warning: do not bury a field you filter and sort on every day inside jsonb. That field will become an index first, and a column soon after.
Where NoSQL genuinely is the right answer
This is not an either-or choice. Used in the right place, specialised stores sitting next to a relational system of record make life easier:
- Key-value (Redis and friends): sessions, cache, queues, rate-limit counters. This is where a caching strategy belongs, not where your records of truth live.
- Document store: forms whose shape differs per customer, configuration snapshots from devices, the chunks an offline-first field app syncs back.
- Search engine: site search relevance, language analysis, typo tolerance. You can fake it in SQL up to a point, and past that point it stops being worth it.
- Time series: sensors, measurements, telemetry. High write volume, almost no updates.
One hard limit to know before you move: a BSON document is capped at 16 MiB, with a maximum nesting depth of 100 levels. The classic trap is an array inside a document that grows without bound. Comments, transactions, log entries. Year one is fine. By year three every read of that document drags megabytes along with it.
A second database is a second operational load
Adding a store is an operations decision as much as an architectural one. Restore drills, monitoring, version upgrades, access control, on-call knowledge: all of it doubles. Then comes the problem of keeping two stores consistent, because code that writes the same fact to two places will eventually write it to one and fail on the other. Most of the pain in ERP and e-commerce synchronisation is exactly this, and it behaves no differently inside your own architecture.
Set a simple rule. A new store has to remove a problem you can name in one sentence. "Search took 4 seconds and now takes 200 milliseconds" is a sentence. "It will scale better" is not.
The scale argument is rarely real
A lot of NoSQL decisions are made for traffic that never arrives. In a mid-sized business application the dataset fits comfortably on one machine, and the real cause of slowness is a missing index or an N+1 query. The order that works: find the slow queries first, then read replicas and caching, then partitioning. Sharding comes last, because it is an operational commitment rather than a configuration flag.
Do not decide on a hunch. Project your row counts and write rates two years out from today's trend and confirm them with a load test. Teams that actually run this calculation usually find the number is one or two orders of magnitude smaller than they assumed.
What your team already knows is a technical criterion
Database choice is not a popularity contest, but ecosystem size translates directly into operational risk. In the 2025 Stack Overflow Developer Survey, PostgreSQL was used by 55.6% of all respondents and 58.2% of professional developers. MySQL came in at 40.5%, SQLite at 37.5%, Redis at 28% and MongoDB at 24%. Those numbers do not tell you which engine is better. They tell you how likely you are to find someone who can fix a failed restore at three in the morning.
Ask your own team three questions. Who can explain a query plan on this engine, who plans the version upgrades, who diagnoses data corruption. If the answer is one person, the choice carries organisational risk even when it is technically sound.
Licensing and provider lock-in reach the contract too
Picking a database pulls in legal and commercial questions. MongoDB Community Server has shipped under the SSPL since October 2018, and MongoDB's own licensing FAQ notes that the licence has not been approved by the Open Source Initiative. Redis, after its 2024 licence change, released Redis 8 under AGPLv3 on 1 May 2025.
If you install the software on a customer's own servers or redistribute it with your product, this belongs to the on-premise delivery model discussion and should be recorded as part of open source licence compliance. The second item is provider lock-in. With managed engines that exist on one cloud only, such as DynamoDB or Firestore, the exit cost is not a migration but a rewrite of your data layer. That is not a reason to avoid them. It is a price worth knowing before you sign.
Write the decision down in half a page
A database choice is among the most expensive decisions to reverse later. Leave half a page behind: which questions this has to answer, which operations must be atomic, the volume estimate two years out, who will operate it, and what a reversal would cost. The value is less in the decision itself than in having an answer when someone asks, two years from now, why it was made this way.
One thing you can do this week
List your product's ten most-used screens and the three most-requested reports. Next to each, write down which entities it reads together. If a lot of those lines touch three entities at once, a relational database is your default and the discussion is over. Then mark the data whose shape genuinely varies and check whether jsonb handles it, because it usually does. Finally, put today's row counts and monthly growth into a table.
Those three lists take an afternoon, and they normally settle the question of whether a second database is needed at all. If you want help reviewing the data layer of an existing system, or getting the storage decision right for a new product, bring these lists along and the conversation moves much faster.
Need help with this topic?