What You Need to Choose and Operate a SaaS Database in 2026

Your database choice is the most consequential technical decision in a SaaS build. Get it wrong and you spend 3 to 6 months migrating under production load instead of shipping features. This guide gives founders, CTOs, and technical leads the decision rules, real 2026 cost numbers, and operational playbooks to pick right the first time and run it well.

10 min read9 sectionsJune 20, 2026

Kostadin Stamboliev

Founder and Imaginator

LinkedIn

Founder and Imaginator at Pineido. Practitioner across IT consulting, app and web development, technical SEO, and AI / automation. Ships production code in 30-day sprints with fixed scope and clear ownership.

PostgreSQL as the 2026 Default: Why the Consensus Holds

PostgreSQL topped the Stack Overflow 2025 Developer Survey as the most-used database for the third consecutive year, with 49% of professional developers reporting it as their primary DB. That number matters because it drives hiring, library support, and managed-service investment. If you start with Postgres, you can hire more engineers, find more answers on Stack Overflow, and choose from more hosting providers than with any other relational database.

For a SaaS product, Postgres gives you relational integrity for billing, subscriptions, and user relationships; JSONB columns for flexible metadata without a schema migration every sprint; a built-in full-text search engine that handles most startup use cases without standing up an Elasticsearch cluster; and row-level security (RLS) policies that enforce tenant isolation at the database layer, not the ORM layer.

The realistic counter-argument for MongoDB is schema flexibility during early product discovery. That argument is weaker than it sounds: a Postgres JSONB column gives you the same flexibility with ACID transactions. The genuine MongoDB advantage is its aggregation pipeline for deeply nested document queries and its horizontal sharding story. If your primary data model is truly document-shaped (e.g., a CMS storing arbitrary user-defined content trees) and you expect to shard before 10M rows, MongoDB is a legitimate choice. For everything else, Postgres is faster to ship, cheaper to operate, and easier to reason about.

Multi-Tenancy Patterns and Row-Level Security

SaaS products isolate tenant data using one of three patterns: separate databases per tenant, separate schemas per tenant, or shared schema with a tenant_id column. Each has a cost and complexity profile you need to pick deliberately.

Separate databases give the strongest isolation and make GDPR deletion trivial, but provisioning hundreds of databases adds operational overhead and cost. PlanetScale and Supabase both support database-per-tenant workflows, but at scale you are paying per database and managing migrations across all of them.

Shared schema with tenant_id is the most common pattern and the one Postgres RLS makes safe. You define a policy like CREATE POLICY tenant_isolation ON orders USING (tenant_id = current_setting('app.current_tenant_id')::uuid) and every query that touches that table automatically filters to the active tenant. The key implementation rule: set the tenant ID in your connection setup (via SET LOCAL or a session variable), never trust application-layer filtering alone.

The risk with RLS is a misconfigured policy that leaks rows across tenants. Mitigate this with automated integration tests that assert a tenant cannot read another tenant's data. Run these in CI on every deploy.

MongoDB's equivalent is field-level filtering combined with application-enforced tenantId on every query. There is no native RLS. You can add middleware enforcement, but it lives at the application layer, not the database layer, which is a weaker guarantee. If your compliance posture requires demonstrable data isolation (SOC 2, HIPAA), Postgres RLS with documented policies is easier to audit.

JSONB, Full-Text Search, and When You Actually Need a Separate Service

Two of the most common reasons teams reach for MongoDB or Elasticsearch are schema flexibility and search. Postgres handles both without an extra service, up to a meaningful scale threshold.

JSONB columns store arbitrary JSON and index it. A GIN index on a JSONB column lets you query nested keys with the same performance characteristics as a dedicated document store for most workloads under a few million rows. The key difference from MongoDB: writes to a JSONB column still participate in Postgres transactions, so you get flexible storage without giving up rollbacks or foreign keys. The cost is that JSONB columns do not enforce a schema, which means drift over time. Use a JSON Schema validation trigger or enforce structure at the API layer.

For full-text search, tsvector and tsquery with a GIN index handle product catalogs, article search, and customer lookup well enough that many SaaS products never need Elasticsearch. The practical threshold is roughly 10M rows with complex relevance tuning, multi-language stemming, and faceted filters. Below that, a to_tsvector index on your content column and a plainto_tsquery query is faster to ship and costs $0 extra.

Where you should still add a dedicated search service: large e-commerce product catalogs with real-time faceting, AI semantic search (which needs a vector database or pg_vector extension), and multi-language SaaS serving non-English markets with complex stemming requirements. For the last case, Typesense is often a better fit than Elasticsearch at startup scale because its operational overhead is lower.

Managed Hosting: Supabase vs RDS vs PlanetScale

The managed vs self-hosted decision is almost always resolved in favor of managed for SaaS startups in 2026. The engineering hours to configure, patch, and operate a self-hosted Postgres cluster cost more than the managed service premium unless you are spending over $5K/mo on database infrastructure.

Supabase Pro starts at $25/mo and includes Postgres, built-in RLS, connection pooling via Supabase Pooler (built on PgBouncer), storage, auth, and edge functions. For an early-stage SaaS with under 50K DAU, this is frequently the entire backend stack. At scale, Supabase Enterprise pricing is negotiated, but teams have reported costs in the $500 to $2,000/mo range for high-traffic workloads.

AWS RDS for PostgreSQL starts around $20/mo for a db.t4g.micro but a production Multi-AZ deployment with reasonable IOPS starts around $300 to $600/mo. At serious scale (db.r6g.2xlarge, Multi-AZ, 500GB storage, 3K IOPS), you are looking at $1,500 to $2,500/mo. RDS gives you more control over instance type, IOPS, and network topology but requires more operational knowledge. Aurora PostgreSQL-compatible gives you a distributed storage layer and can handle more concurrent connections, at roughly 20-30% higher cost than RDS for equivalent compute.

PlanetScale (MySQL-compatible) removed its free tier in 2024, with production plans starting at $39/mo. Its branching workflow is excellent for schema migrations and its horizontal sharding story is strong, but the MySQL compatibility layer means some Postgres-specific features (RLS, JSONB, pg_vector) are unavailable. It is the right call for teams that need horizontal write scaling before they hit Postgres's natural ceiling, typically above 10K write transactions per second sustained.

Connection Pooling, PgBouncer, and Why This Breaks Production

Postgres creates a process per connection. At 200 open connections on a standard instance, memory pressure starts degrading query performance. A typical Node.js or Python service with 10 worker processes and a pool of 20 connections each can hit 200 connections within minutes of deploying to a modest cluster. This is one of the most common causes of production outages on early-stage SaaS products.

PgBouncer solves this by multiplexing many application connections onto a smaller set of actual database connections. In transaction pooling mode, PgBouncer holds a server connection only while a transaction is in progress and returns it to the pool immediately after, allowing you to serve thousands of application connections with 20-30 server connections. The constraint: in transaction pooling mode, session-level features like prepared statements and advisory locks do not work as expected. Supabase's built-in Supabase Pooler uses PgBouncer under the hood with transaction pooling, which is why some ORMs (Prisma, in particular) require explicit pgbouncer=true in the connection string.

The practical setup for 2026: connect your application to PgBouncer or Supabase Pooler on port 6543 (transaction mode), and use the direct database port 5432 only for migrations and admin tasks. Set your application pool size to 5 to 10 connections per process, not the ORM default of 20 to 100. This alone prevents most connection exhaustion incidents.

For high-concurrency APIs (over 1K concurrent requests), consider Pgpool-II for load balancing across a primary and read replicas, routing read-only queries to replicas automatically. This effectively doubles your read throughput at the cost of replication lag visibility.

Backup, PITR, RPO and RTO: What They Mean in Practice

Recovery Point Objective (RPO) is the maximum data loss you can tolerate. Recovery Time Objective (RTO) is the maximum downtime you can tolerate. A $25/mo Supabase Pro plan gives you 7-day point-in-time recovery (PITR) by default. AWS RDS gives you up to 35 days of automated PITR. Both use continuous WAL (Write-Ahead Log) archiving, meaning you can recover to any second within the retention window.

For a B2B SaaS with enterprise customers, your SLA likely requires an RPO under 1 hour and an RTO under 4 hours. Both Supabase and RDS satisfy this by default. If you need sub-minute RPO (financial transactions, healthcare records), you need a Multi-AZ deployment with synchronous replication, which means your primary waits for the standby to confirm each write. This adds 1-5ms latency per write but ensures no committed transaction is lost on a primary failure.

Test your recovery process quarterly. The most common failure mode is not the backup failing, it is the team not knowing the restore procedure under pressure at 2 AM. Run a restore drill to a staging environment, time it, and document the steps. On RDS, a point-in-time restore to a new instance takes 15 to 45 minutes depending on database size. On Supabase, you can use the dashboard to trigger a restore or use the Supabase CLI.

For MongoDB Atlas (the managed offering), automated backups with PITR are available on M10+ clusters (starting at $0.09/hour, roughly $65/mo). Atlas also supports cloud provider snapshots on a configurable schedule. The operational model is comparable to RDS.

Slow Query Identification, Indexing Strategy, and Real Performance Wins

The single highest-return database optimization is finding and indexing the 5 queries that account for 80% of your load. You do not need a consultant for this. You need pg_stat_statements enabled and 30 minutes.

Enable pg_stat_statements with CREATE EXTENSION pg_stat_statements and query it weekly: SELECT query, calls, mean_exec_time, total_exec_time FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20. The queries at the top are where your database time goes. Most startups find 2 to 4 queries that account for over 60% of total execution time, and most of those are missing a simple index.

For structured log analysis, pgBadger parses Postgres log files and generates an HTML report showing slowest queries, most frequent queries, and lock wait events. It is free and takes about 10 minutes to run on a day's worth of logs. On RDS, enable Performance Insights (free for 7 days, $0.02/vCPU-hour after) for a real-time query dashboard.

Indexing rules that pay off immediately: add a B-tree index on every foreign key column (Postgres does not do this automatically, unlike MySQL), every column that appears in a WHERE clause on a table over 100K rows, and every column used in an ORDER BY on paginated queries. Partial indexes (e.g., CREATE INDEX ON orders (created_at) WHERE status = 'pending') are often 10-50x smaller than full indexes and faster for common filtered queries.

For JSONB columns, use a GIN index when querying for key existence or containment. For extracting a specific JSONB field repeatedly, create a generated column and index that instead. A GIN index on a large JSONB column can add 200-400ms to writes, so profile before indexing everything.

Migrating from SQLite, MySQL, or DynamoDB: Real Costs

The most expensive database decision is migrating away from the wrong one under production load. Here is what each migration actually costs in 2026 in engineering time.

SQLite to Postgres: SQLite is often the initial choice for small apps or Electron-style desktop products. Migration is straightforward because the SQL dialects are close. Expect 1 to 2 weeks of engineering time for a small schema (under 50 tables), mostly spent adjusting data types (SQLite's loose typing vs Postgres's strict types), rewriting triggers, and updating connection code. Use pgloader for the data migration itself.

MySQL to Postgres: More involved. Key differences are string quoting rules, ENUM handling, full-text search syntax, and JSON support. Budget 2 to 4 weeks for a production SaaS schema. PlanetScale's migration tooling can help if you are already on PlanetScale. For vanilla MySQL, pgloader handles most type coercions automatically.

DynamoDB to Postgres: This is the most expensive migration and the one teams most regret triggering. DynamoDB's access pattern-driven design means your table structure often does not map cleanly to relational rows. Budget 4 to 12 weeks depending on schema complexity, and expect to redesign core data models, not just move data. Teams that made the DynamoDB decision for operational simplicity (no schema, serverless) frequently report this migration costing $40K to $120K in engineering time at 2026 US market rates ($150 to $250/hour for a senior backend engineer).

The migration from MongoDB to Postgres is similar in duration to DynamoDB. If your documents have variable structure that is genuinely load-bearing, you may end up with a hybrid: core entities in relational tables, flexible metadata in JSONB. That hybrid is often the correct landing spot.

Shipping the Right Database Setup as a Fixed-Scope Sprint

Getting the database layer right from day one is a concrete scoping exercise, not an ongoing negotiation. A well-defined sprint covers: schema design with RLS policies for multi-tenancy, connection pooling configuration, backup and PITR verification, indexing strategy for the initial query set, and a migration path document if you are moving from an existing system.

Pineido scopes database architecture and implementation as part of fixed-price 30-day app sprints. If you are evaluating what the right setup costs for your SaaS, the relevant starting point is the custom app and web development sprint at /services/app-web-development. The scope is defined before any work starts, so you know exactly what you are getting without a time-and-materials surprise.

Frequently asked questions

Should I use PostgreSQL or MongoDB for a new SaaS in 2026?

Use PostgreSQL unless your primary data model is deeply nested documents with genuinely variable structure. Postgres handles flexible data via JSONB with full ACID guarantees, enforces multi-tenant isolation with row-level security, and runs full-text search without a separate service. MongoDB has a stronger sharding story and a better aggregation pipeline for document-heavy workloads, but most SaaS products never need either until after product-market fit.

How does row-level security work in PostgreSQL for multi-tenant SaaS?

You create a policy on each tenant-scoped table using CREATE POLICY, referencing a session variable your application sets at connection time (e.g., current_setting('app.current_tenant_id')). Every query on that table automatically appends the tenant filter at the database layer. This is safer than application-layer filtering because a bug in your ORM cannot leak rows. Test every policy with automated cross-tenant access tests in CI.

Why does my Postgres instance crash at high traffic and how do I fix it?

Postgres creates one OS process per connection. Without pooling, a Node.js cluster with 20 processes and a pool size of 20 opens 400 connections and triggers memory exhaustion. Fix it by routing all application connections through PgBouncer or Supabase Pooler in transaction mode. Set your application pool size to 5-10 per process. Reserve the direct database port for migrations only.

What backup and recovery setup do I need for a SaaS database?

At minimum, enable point-in-time recovery (PITR). Supabase Pro includes 7-day PITR; RDS supports up to 35 days. For an RPO under 1 hour and RTO under 4 hours, the defaults on both platforms suffice. For financial or healthcare data requiring sub-minute RPO, use Multi-AZ with synchronous replication, which adds 1-5ms write latency but guarantees no committed transaction is lost on primary failure. Test your restore procedure quarterly.

What does a SaaS database cost per month in 2026?

Supabase Pro starts at $25/mo with PITR, auth, and connection pooling included. A production RDS Multi-AZ deployment starts around $300-600/mo. Serious scale (db.r6g.2xlarge, Multi-AZ, 500GB storage) runs $1,500-2,500/mo on RDS. MongoDB Atlas starts at roughly $65/mo for production-grade M10 clusters. Self-hosting saves money on the infrastructure line item but shifts cost to engineering time, which is nearly always more expensive.

How much does it cost to migrate from DynamoDB to PostgreSQL?

Budget 4-12 weeks of senior backend engineering depending on schema complexity. DynamoDB's access-pattern-driven design rarely maps cleanly to relational tables, so you typically redesign core data models rather than just moving data. At 2026 US market rates ($150-250/hr for a senior backend engineer), that migration costs $40K-120K. This is why the database choice at the start of the project matters so much.

Ready to ship?

Tell us where you are stuck. We will review it and send a focused recommendation within one business day.

Get operations insights weekly

Join service-business operators who get one actionable insight on ops, automation, and growth every week.

Checking that you're human. You can send in a moment.

No spam. Unsubscribe anytime.

You’re subscribed! Look for our next issue in your inbox.