Back to Home

PostgreSQL on Azure: A Migration POC

A comparative analysis of Azure Cosmos DB (Citus) vs. Flexible Server. Validated cross-cloud compatibility and achieved sub-second execution on complex procedures.

The Migration Challenge

Moving from a massive on-premise Oracle environment to a managed cloud database is rarely a 1-to-1 lift and shift. Our core database handled complex PL/SQL procedures, heavy transactional traffic, and large volumes of unstructured XML data. Our goal was to modernize the architecture by moving to PostgreSQL on Azure, but we needed to determine the right deployment model.

Cosmos DB (Citus) vs Flexible Server

We set up a Proof of Concept (POC) to test two primary Azure offerings for PostgreSQL: Cosmos DB for PostgreSQL (formerly Citus) for distributed workloads, and Azure Database for PostgreSQL Flexible Server for consolidated, vertically-scaled architectures.

Azure Cosmos DB for PostgreSQL offered excellent distributed capabilities. By sharding our multi-tenant data, we could route queries to specific worker nodes, dramatically decreasing read latency for localized tenant reports. However, the overhead of modifying our heavy monolithic PL/SQL procedures to run across distributed nodes was high.

Azure Flexible Server offered high availability with zone redundancy, pgBouncer integration natively, and a much smoother transition path for our existing Oracle stored procedures (via Ora2Pg translation).

Performance Validation

During the POC, we benchmarked complex daily reconciliation procedures. After re-writing the PL/SQL loops into set-based PostgreSQL queries and applying strategic indexing, Flexible Server achieved sub-second execution times for critical API endpoints.

We ultimately decided on Flexible Server for the initial migration phase to minimize code re-writes, with a long-term architectural roadmap to carve out multi-tenant microservices into Cosmos DB instances.