postgresqlgoogle-cloud-platformgoogle-cloud-sqlread-replication

What is the replication method used for the GCP CloudSQL Read Replica for Postgresql


Based on the descriptions it seems that for the Read Replicas for Postgresql, the Write-Ahead Log Shipping is used. Is it logical? I have tables without primary keys, however when I spin up a read replica I have no problems so wonder what is being used behind the scenes.


Solution

  • Cloud SQL "native" Postgres replicas (e.g., those you create via Cloud Console/gcloud/API) uses Postgres' built-in streaming physical replication which involves WAL segment shipping from primary to replica(s).

    The needing primary keys is a constraint that exists in logical replication using an extension like pg_logical. You can configure your own replication relationships using pg_logical (as well as postgres' own built in logical decoding on versions that support it) in Cloud SQL but this isn't the same as native replication offering which is fully managed by Google.

    But to answer your question directly: Cloud SQL's native read replicas, like the one you referred, uses WAL shipping (physical/streaming replication) as you suspect. Which is why your tables replicate just fine without primary keys.