Cloud SQL for MySQL & PostgreSQL
While the Cloud SQL Overview covered the service at a high level, this lesson dives deeper into engine-specific features, configuration, and best practices for MySQL and PostgreSQL on Cloud SQL. These are the two most commonly used engines on the platform, and each has unique capabilities worth understanding.
Cloud SQL for MySQL
Supported Versions
Cloud SQL supports MySQL 5.6, 5.7, and 8.0. MySQL 8.0 is recommended for all new instances — it includes performance improvements, window functions, CTEs (Common Table Expressions), and improved JSON support.
Key Features
- InnoDB storage engine — the default and only production-supported engine on Cloud SQL.
- Binary log replication — enables read replicas and point-in-time recovery.
- Database flags — over 100 MySQL flags can be configured (e.g.
max_connections, innodb_buffer_pool_size, slow_query_log).
- Character sets — supports UTF-8, UTF-8MB4 (recommended for emoji and full Unicode), and other character sets.
Read Replicas
Cloud SQL for MySQL supports read replicas for scaling read-heavy workloads:
- Up to 10 read replicas per primary instance.
- Replicas can be in the same region or cross-region for disaster recovery.
- Replication is asynchronous using MySQL binary log replication.
- Read replicas can be promoted to a standalone instance if needed.
External Replication
You can configure external replication to replicate data between Cloud SQL and an external MySQL server:
- Inbound replication — replicate from an external MySQL server to Cloud SQL (useful for migration).
- Outbound replication — replicate from Cloud SQL to an external server (useful for hybrid architectures).
Cloud SQL for PostgreSQL
Supported Versions
Cloud SQL supports PostgreSQL 12 through 16. PostgreSQL 16 is recommended for new instances — it offers improved parallelism, logical replication enhancements, and performance optimisations.
Key Features
- Extensions — Cloud SQL supports a wide range of PostgreSQL extensions including PostGIS (geospatial), pgvector (AI/ML embeddings), pg_trgm (text search), and many more.
- pgAudit — database activity auditing for compliance requirements.
- Logical replication — enables replication of specific tables or databases rather than the entire instance.
- Database flags — configure PostgreSQL parameters such as
work_mem, shared_buffers, max_connections, and log_min_duration_statement.
Read Replicas
Cloud SQL for PostgreSQL supports read replicas:
- Up to 10 read replicas per primary.
- Cross-region replicas for disaster recovery and global read performance.
- Replication uses PostgreSQL streaming replication (physical replication).
- Cascading replicas are supported — a replica can itself have replicas.