Postgres, MongoDB or Firebase for a new SaaS: how we choose

How we choose a database for a new SaaS: why PostgreSQL is our default, when MongoDB or Firebase fit better, and the questions that decide it.

The short answer

We default to PostgreSQL for a new SaaS, because business data is relational, multi-tenant isolation can be enforced inside the database, and one database can also run queues, locks, full-text search and geography. MongoDB fits genuinely document-shaped data with few relations. Firebase fits small real-time apps where you accept vendor lock-in and limited queries.

On this page
  1. What do the three actually offer?
  2. Why is PostgreSQL our default?
  3. When does MongoDB make sense?
  4. When does Firebase make sense?
  5. What about “it won’t scale”?
  6. What decides it? Five questions
  7. Can you start simple and change later?
  8. What else matters besides the engine?
  9. What are the common database mistakes in a new SaaS?
  10. Working with us

The database choice is one of the few early decisions that is expensive to reverse. Here is how we choose, with the reasons, so you can check them against your own product.

What do the three actually offer?

PostgreSQL MongoDB Firebase (Firestore)
Model Relational tables, plus JSON columns Documents (JSON-like) Documents in collections, hosted
Relations and joins Native, with constraints Possible, weaker No joins; you copy data
Transactions Full, across tables Supported, with limits Limited
Tenant isolation inside the database Row-level security Application-level Security rules
Queries SQL: anything you can think of Rich query language Limited to what indexes allow
Hosting Anywhere, many providers Anywhere, or Atlas Google only
Extras Full-text search, geography (PostGIS), queues, locks Search and more in the paid cloud Real-time sync, auth, hosting bundled

Why is PostgreSQL our default?

  1. Business data is relational. Customers have orders, orders have items, bookings link to tables and guests. Foreign keys and constraints stop bad data entering. In a document database, the application has to do that and eventually someone forgets.
  2. Multi-tenant isolation inside the database. With row-level security, PostgreSQL refuses to return another tenant’s rows even if a query is wrong. We test this in CI for every table: proving tenant isolation.
  3. Fewer services. PostgreSQL can run our job queues (pg-boss), advisory locks that keep scheduled jobs safe when two servers run, full-text search, and geographic queries. Mesito stores buyers’ search areas as geography, so the database answers “is this property inside the area?”. Each extra stateful service is one more thing to back up and replicate: saas-ready-to-move-servers.
  4. You can leave. It runs on any server and on every major cloud, so moving provider is a config and a restore, not a rewrite.
  5. Reporting. SQL lets you answer questions nobody planned for, which is every question a growing business asks.
  6. Flexibility where needed. JSON columns store free-form data inside a relational design.

When does MongoDB make sense?

  • The data is a document: variable structure, deeply nested, read and written as a whole, with few relations. Content management, catalogues with very different attributes, event or log data.
  • You have a team with deep MongoDB experience and a specific scale pattern that suits it.

The warning sign is a “document” that keeps needing references to other documents. At that point you rebuild joins in application code. For most business SaaS, a JSON column in PostgreSQL covers the flexible parts.

When does Firebase make sense?

  • A prototype or small product where real-time sync, authentication and hosting in one package get you to users fastest.
  • Simple data shapes and access patterns known in advance.
  • You accept lock-in to one vendor.

The costs show later: you design collections around the queries you expect, reporting is awkward, access rules live in a separate rules language, costs scale with reads and writes, and leaving means rewriting the data layer. If you think you will need reports, tenants, roles and an API for customers, choose a relational database from the start.

What about “it won’t scale”?

For a young SaaS, no. PostgreSQL handles far more than most products ever reach on one properly configured server. Scale problems in early products come from missing indexes, queries that load too much, and chatty code, not from the database type. Measure first. When you do need more, you add read replicas, partitioning or caching. Our products run on a single server today.

What decides it? Five questions

  1. Is the data mostly related records? If yes, PostgreSQL.
  2. Do you need tenant isolation you can prove? PostgreSQL.
  3. Will customers or your team need reports and exports? PostgreSQL.
  4. Is the data genuinely a set of independent documents, with a clear access pattern? MongoDB may fit.
  5. Is this a short-lived prototype where speed to first user beats everything? Firebase may fit, with an exit plan.

Can you start simple and change later?

You can, but plan for it. Keep data access in one layer, do not let the database’s quirks leak into the whole code base, keep schema changes as migrations, and write down the data model. Moving a live product between databases is possible, but it takes rehearsals and comparison. We did it on a live CRM, and what worked is in moving a live CRM to PostgreSQL.

What else matters besides the engine?

  • Backups you have restored. A backup you never restored is a guess: nightly restore drills.
  • Managed or self-run. A managed database costs money but saves operational work. A self-run one is cheaper and needs discipline. Decide knowing which you have the people for.
  • Migrations. Add first, remove later, so two versions of the app can run during a deploy.

What are the common database mistakes in a new SaaS?

Whatever you pick, these cost money later:

  • No tenant id on a table until the second customer arrives.
  • Money stored as floating-point numbers instead of integer amounts with a currency code.
  • Time stored without a time zone.
  • Free-text status columns with no rules for which changes are allowed.
  • Files stored in the database or on the server’s disk instead of in object storage.
  • No test that restores a backup into a clean database.

Each is cheap to avoid in the first week and expensive to fix in the second year.

Working with us

We design and build SaaS platforms on PostgreSQL, and we will tell you if your product is one of the exceptions. Describe your data and your plans through the contact page, or see our SaaS platform work.

Keep reading

Tell us what you want to build.

A product, a website, a search problem or a system that should work better. We reply with a plain answer and the first step.

A few sentences are enough (at least 20 characters).

We use your details only to answer your inquiry. See our privacy policy.