Azure Cosmos DB for PostgreSQL is Microsoft’s solution for horizontal scaling of relational databases on a PostgreSQL foundation. The service was previously known as “Azure Database for PostgreSQL – Hyperscale (Citus)” and was repositioned under the Cosmos DB brand in 2022. At its core, it is based on the open-source Citus extension that Microsoft acquired.
Citus Architecture: Distributed PostgreSQL
The foundation of Cosmos DB for PostgreSQL is the Citus extension for PostgreSQL. Citus adds a horizontal sharding model to PostgreSQL: data is distributed across multiple worker nodes based on a defined shard column. A coordinator node accepts queries, analyzes the query plan, and coordinates parallel execution across the worker nodes. From the application’s perspective, the coordinator looks like an ordinary PostgreSQL instance, ensuring compatibility with existing applications and tools. PostgreSQL extensions, stored procedures, and standard SQL syntax work unchanged as long as queries are formulated in a shard-aware manner.
This model enables horizontal scaling for workloads that would hit limits on a single PostgreSQL server: multi-tenant SaaS applications with millions of tenants, time-series databases with high write throughput, or analytics workloads on large data volumes. As a managed service, Microsoft handles patching, backups, high availability with automatic failover, and monitoring.
Use Cases: Multi-Tenant and Analytics
Two architecture patterns dominate the use of Cosmos DB for PostgreSQL. The first is multi-tenant SaaS architecture: the tenant ID serves as the shard column, so all data for a tenant resides on the same worker node. This enables efficient queries within a tenant and simple data isolation. The second pattern is time-series data and analytics: the distributed write throughput allows very high ingestion rates, and parallel aggregation queries across all worker nodes benefit from horizontal scaling. For standard OLTP workloads with predictable access patterns, Azure Database for PostgreSQL Flexible Server is the simpler and often sufficient alternative.
Typical Use Cases
Frequently Asked Questions
What is the difference from Azure Database for PostgreSQL Flexible Server?
Azure Database for PostgreSQL Flexible Server is a managed single-node PostgreSQL service for standard workloads. Cosmos DB for PostgreSQL (Citus) is a distributed cluster with multiple worker nodes that scales horizontally. For most applications, Flexible Server is sufficient; Cosmos DB for PostgreSQL is suited for very large data volumes and high-load scenarios.
What is Citus and how does sharding work?
Citus is an open-source PostgreSQL extension that distributes data across multiple worker nodes. A table is split into shards based on a shard column. The coordinator node receives queries, identifies the relevant shards, and coordinates parallel execution across the worker nodes.
Is Cosmos DB for PostgreSQL fully PostgreSQL-compatible?
Largely yes. Since it is a PostgreSQL extension, standard SQL queries, transactions, and many PostgreSQL features work. Some operations (e.g., cross-shard JOINs without a shard column) require query adjustments.
