Skip to main content

GCP - Google Cloud SQL for PostgreSQL

Google Cloud Platform CloudSQL for PostgreSQL agent setup

For an overview of how the DBtune agent works, see agent overview.

Prerequisites

Before starting the DBtune agent, ensure you have completed the database setup steps.

Google Cloud Platform IAM permissions

The agent is setup to use the application default credentials. The credentials provided to the agent need at least the following permissions:

  • cloudsql.databases.get
  • cloudsql.databases.update
  • cloudsql.instances.get
  • cloudsql.instances.list
  • cloudsql.instances.update
  • monitoring.timeSeries.list

Setting up the agent

Run the DBtune agent using Docker with Cloud SQL-specific configuration:

docker run --restart always --detach \
-e DBT_POSTGRESQL_CONNECTION_URL="postgresql://..." \
-e DBT_GCP_PROJECT_ID={gcp_project_id} \
-e DBT_GCP_DATABSE_NAME={gcp_cloudsql_database_name} \
-e DBT_DBTUNE_SERVER_URL=https://app.dbtune.com \
-e DBT_DBTUNE_API_KEY=your-dbtune-api-key \
-e DBT_DBTUNE_DATABASE_ID=your-dbtune-database-id \
public.ecr.aws/dbtune/dbtune/agent:latest --cloudsql

For information about common environment variables (DBT_DBTUNE_* and DBT_POSTGRESQL_*), see agent overview - common environment variables.

Google Cloud Platform SQL-specific environment variables

VariableDescription
DBT_GCP_PROJECT_IDIdentifier of the Google Cloud Platform project where the database is located.
DBT_GCP_DATABSE_NAMEName of the Cloud SQL database instance.

Parameters tuned

DBtune supports multiple tuning modes that determine which parameters can be optimized. For a detailed explanation of tuning modes, see tuning modes.

Reload-only tuning mode

The following parameters are tuned in reload-only mode:

  1. work_mem
  2. random_page_cost
  3. seq_page_cost
  4. checkpoint_completion_target
  5. effective_io_concurrency
  6. max_parallel_workers_per_gather
  7. max_parallel_workers
  8. max_wal_size
  9. min_wal_size
  10. bgwriter_lru_maxpages
  11. bgwriter_delay
  12. maintenance_work_mem
  13. default_statistics_target
  14. max_parallel_maintenance_workers

Restart tuning mode

The following parameters are tuned in restart mode, in addition to all reload-only parameters:

  1. shared_buffers
  2. max_worker_processes
  3. wal_buffers