An Azure managed PostgreSQL database service for app development and deployment.
Hi Satyam Sinha & thx for join me at Q&A platform,
ur testing points pretty strongly toward WAL flush latency rather than slow SQL execution, especially with the difference between synchronous_commit=on and off.
The most useful evidence is that inserts consistently finish in under 1 ms, while synchronous commits take 76–389 ms. With synchronous_commit=off, the commit latency drops to almost nothing. Combined with the IO/WALSync wait events, that suggests PostgreSQL is spending a significant amount of time waiting for WAL durability operations to complete.
Disabling zone-redundant HA was a reasonable test, but it doesn't eliminate the requirement to flush WAL to durable storage for local commits. So the fact that latency remains high with HA disabled makes synchronous standby replication less likely to be the explanation, but it doesn't rule out storage-side latency.
I'd also pay attention to the LWLock/WALWrite waits. Those can indicate contention between backends trying to write or flush WAL. If one backend is experiencing a slow flush, other concurrent transactions may end up waiting behind it. That could explain why ur commit latency occasionally reaches 300–400 ms even with relatively low WAL generation.
The low WAL throughput and unchanged checkpoint counters are useful observations, but neither rules out a storage problem. Small synchronous writes can have high latency even when total IOPS and throughput are low. And WAL flushing is separate from normal checkpoint activity.
I'd compare PROD and INT at the infrastructure level next: compute SKU, storage configuration, provisioned IOPS, storage utilization, and Azure Monitor disk I/O metrics. Look for differences in write latency, IOPS consumption, throttling, or disk queue behavior around the affected timestamps. Also check whether the problem persists during low-traffic periods with only one connection performing small transactions.
One particularly useful test would be to run the same controlled transaction workload against PROD and INT with a single connection, then repeat with multiple concurrent connections. If PROD still shows 76–110 ms commits with only one active writer, that would make application-level contention a less convincing explanation and put more focus on the WAL durability path.
I wouldn't recommend disabling synchronous_commit globally as a workaround. It reduces commit latency by allowing PostgreSQL to acknowledge transactions before their WAL records are durably flushed, which introduces a potential data-loss window if the server crashes.
Also, track_wal_io_timing being read-only is a managed-service limitation, so I wouldn't spend more time trying to enable it. You've already collected enough evidence to justify a deeper investigation.
At this point, I'd open an Azure Database for PostgreSQL Flexible Server support case and request service-side storage and WAL flush latency diagnostics. Include the PROD/INT comparison, exact UTC timestamps, PostgreSQL version, compute and storage configurations, wait-event samples, and the controlled synchronous_commit test results.
Specifically, ask engineering to check whether the underlying storage path is experiencing elevated flush latency, whether any I/O throttling is occurring, and whether there are host-level or service-side conditions affecting WAL durability operations.
A consistent 76–110 ms synchronous commit time compared with 1–1.5 ms in INT is a substantial difference, and I wouldn't consider it normal without an explanation tied to the actual infrastructure configuration.
One question: are PROD and INT using the same compute tier, VM size, storage type, and provisioned IOPS? If they're comparable and PROD still shows this behavior under a single-connection test, that would strengthen the case for an Azure-side investigation quite a bit.
rgds,
Alex
p.s. if my answer is help - pls mark it as an answer