← Back to list

PostgreSQL, MongoDB, or Distributed SQL (Yugabyte DB/ Cockroach DB)?

When engineers talk about microservices, they usually focus on APIs, Kubernetes, Kafka, or service discovery.

Syntax & Symphony · 2026-07-19 10:40 · 5 claps · 2.4 min read
#software-development #postgresql #mongodb #yugabytedb #cockroachdb
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud ⏱️ · Productivity

PostgreSQL, MongoDB, or Distributed SQL (Yugabyte DB/ Cockroach DB)? Your Architecture Depends on It

When engineers talk about microservices, they usually focus on APIs, Kubernetes, Kafka, or service discovery.

But one decision quietly shapes your entire architecture:

The database.

Choose the wrong database, and your microservices slowly become bloated with routing logic, retries, synchronization code, and data stitching.

Choose the right one, and much of that complexity stays where it belongs — inside the database.

Today, most architectures fall into one of three categories:

  • Classic SQL (PostgreSQL)
  • NoSQL (MongoDB, DynamoDB)
  • Distributed SQL (YugabyteDB, CockroachDB)

Each one changes what your application has to do.

1. The NoSQL Path

Examples: MongoDB, DynamoDB

The promise is simple:

Scale almost infinitely.

To achieve that, these databases are optimized for horizontal scaling and flexible schemas rather than complex relational operations.

That changes what your microservices are responsible for.

Application-Level Relationships

Imagine an Order Service needs:

  • Customer
  • Address
  • Payment
  • Product

In PostgreSQL, much of this can be retrieved through SQL joins.

In document or key-value databases, data is often denormalized or spread across multiple collections or tables.

Your service now becomes responsible for combining that data.

Instead of one SQL query, your code may execute several database calls and assemble the response.

Your application becomes the query engine.

2. The PostgreSQL Path

PostgreSQL is arguably one of the greatest databases ever built.

You get:

  • ACID transactions
  • joins
  • foreign keys
  • mature indexing
  • excellent SQL support

Life is wonderfully simple.

BEGIN;

UPDATE inventory
SET quantity = quantity - 1
WHERE product_id = 10;

INSERT INTO orders (...);
COMMIT;
Done.

The database guarantees consistency.

Your service stays clean.

Where It Starts Hurting

The challenge isn’t functionality.

It’s scale.

A traditional PostgreSQL deployment is fundamentally centered around a primary server.

You can scale vertically for a long time, but eventually you’ll need strategies like:

  • read replicas
  • partitioning
  • sharding
  • failover clusters

Some organizations even implement application-aware routing so different requests go to different database partitions.

At that point, your application starts understanding physical database topology — a concern that ideally belongs below the application layer.

3. Distributed SQL

Examples:

  • YugabyteDB
  • CockroachDB

Distributed SQL databases try to combine two worlds:

  • relational database features
  • distributed infrastructure

From the application’s perspective, you’re still writing SQL.

Behind the scenes, the database automatically:

  • shards data
  • replicates data
  • elects leaders
  • recovers from node failures
  • balances data across the cluster

Your microservice doesn’t need to know where the data physically lives.

What Gets Simpler?

No Manual Sharding

Instead of writing routing logic inside your services,

the database decides where data belongs.

Your application continues talking to what appears to be a single SQL database.

Built-in Distributed Transactions

Transactions can span multiple nodes inside the cluster.

The storage engine coordinates the complexity.

Instead of worrying about which machine owns which row,

developers simply write SQL.

High Availability

If one node disappears,

another replica takes over automatically.

Your services usually don’t need custom failover logic.

What Doesn’t Disappear?

Distributed SQL is powerful, but it doesn’t solve every distributed systems problem.

If your Order Service, Payment Service, and Shipping Service each own separate databases, you still need patterns such as:

  • Saga
  • Outbox Pattern
  • Idempotency
  • Retry mechanisms

The database can guarantee consistency within its transactional boundary, but it cannot automatically coordinate independent services that intentionally own separate data.

The Bigger Lesson

Database selection isn’t just a storage decision.

It’s an architectural decision.

Every feature missing from the database usually appears somewhere else — in your application code.

Sometimes that’s the right trade-off.

Sometimes it’s not.

The real question isn’t:

“Which database is the fastest?”

The better question is:

Where do I want the complexity to live?”

Because complexity never disappears.

It simply moves.

Sometimes it lives inside the database.

Sometimes it lives inside thousands of lines of application code.

The best architects understand that choosing a database is really choosing where that complexity belongs.


메타데이터
post_id
2bf4a3592fbe
slug
postgresql-mongodb-or-distributed-sql-yugabyte-db-cockroach-db-2bf4a3592fbe
url
https://medium.com/@syntaxAndSymphony/postgresql-mongodb-or-distributed-sql-yugabyte-db-cockroach-db-2bf4a3592fbe
canonical_url
https://medium.com/@syntaxAndSymphony/postgresql-mongodb-or-distributed-sql-yugabyte-db-cockroach-db-2bf4a3592fbe
author_url
https://medium.com/@syntaxAndSymphony
status
ok
fetched_at
2026-08-29 00:48:47