This page describes how to configure database flags for Cloud SQL, and lists the flags that you can set for your instance. You use database flags for many operations, including adjusting PostgreSQL parameters, adjusting options, and configuring and tuning an instance.
In some cases, setting one flag may require that you set another flag to fully enable the functionality you want to use.
When you set, remove, or modify a flag for a database instance, the database might be restarted. The flag value is then persisted for the instance until you remove it. If the instance is the source of a replica, and the instance is restarted, the replica is also restarted to align with the current configuration of the instance.
Configure database flags
The following sections cover common flag management tasks.
Set a database flag
Console
- In the Google Cloud console, select the project that contains the Cloud SQL instance for which you want to set a database flag.
- Open the instance and click Edit.
- Go to the Flags section.
- To set a flag that has not been set on the instance before, click Add item, choose the flag from the drop-down menu, and set its value.
- Click Save to save your changes.
- Confirm your changes under Flags on the Overview page.
gcloud
Edit the instance:
gcloud sql instances patch INSTANCE_NAME --database-flags=FLAG1=VALUE1,FLAG2=VALUE2
This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags you want set on the instance; any flag not specifically included is set to its default value. For flags that don't take a value, specify the flag name followed by an equals sign ("=").
For example, to set the log_connections and
log_min_error_statement flags, you
can use the following command:
gcloud sql instances patch INSTANCE_NAME \ --database-flags=log_connections=on,log_min_error_statement=error
Terraform
To add database flags, use a Terraform resource.
Apply the changes
To apply your Terraform configuration in a Google Cloud project, complete the steps in the following sections.
Prepare Cloud Shell
- Launch Cloud Shell.
- 
    Set the default Google Cloud project where you want to apply your Terraform configurations. You only need to run this command once per project, and you can run it in any directory. export GOOGLE_CLOUD_PROJECT=PROJECT_ID Environment variables are overridden if you set explicit values in the Terraform configuration file. 
Prepare the directory
Each Terraform configuration file must have its own directory (also called a root module).
- 
    In Cloud Shell, create a directory and a new
    file within that directory. The filename must have the
    .tfextension—for examplemain.tf. In this tutorial, the file is referred to asmain.tf.mkdir DIRECTORY && cd DIRECTORY && touch main.tf 
- 
    If you are following a tutorial, you can copy the sample code in each section or step. Copy the sample code into the newly created main.tf.Optionally, copy the code from GitHub. This is recommended when the Terraform snippet is part of an end-to-end solution. 
- Review and modify the sample parameters to apply to your environment.
- Save your changes.
- 
    Initialize Terraform. You only need to do this once per directory.
    terraform init Optionally, to use the latest Google provider version, include the -upgradeoption:terraform init -upgrade 
Apply the changes
- 
    Review the configuration and verify that the resources that Terraform is going to create or
    update match your expectations:
    terraform plan Make corrections to the configuration as necessary. 
- 
    Apply the Terraform configuration by running the following command and entering yesat the prompt:terraform apply Wait until Terraform displays the "Apply complete!" message. 
- Open your Google Cloud project to view the results. In the Google Cloud console, navigate to your resources in the UI to make sure that Terraform has created or updated them.
Delete the changes
To delete your changes, do the following:
- To disable deletion protection, in your Terraform configuration file set the
            deletion_protectionargument tofalse.deletion_protection = "false" 
- Apply the updated Terraform configuration by running the following command and
            entering yesat the prompt:terraform apply 
- 
             Remove resources previously applied with your Terraform configuration by running the following command and entering yesat the prompt:terraform destroy 
REST v1
To set a flag for an existing database:
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
HTTP method and URL:
PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
Request JSON body:
{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "flag_name",
        "value": "flag_value"
      }
    ]
  }
}
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
If there are existing flags configured for the database, modify the previous
command to include them. The PATCH command overwrites the existing
flags with the ones specified in the request.
REST v1beta4
To set a flag for an existing database:
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
HTTP method and URL:
PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
Request JSON body:
{
  "settings":
  {
    "databaseFlags":
    [
      {
        "name": "flag_name",
        "value": "flag_value"
      }
    ]
  }
}
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
If there are existing flags configured for the database, modify the previous
command to include them. The PATCH command overwrites the existing
flags with the ones specified in the request.
Clear all flags to their default values
Console
- In the Google Cloud console, select the project that contains the Cloud SQL instance for which you want to clear all flags.
- Open the instance and click Edit.
- Open the Database flags section.
- Click the X next to all of the flags shown.
- Click Save to save your changes.
gcloud
Clear all flags to their default values on an instance:
gcloud sql instances patch INSTANCE_NAME \ --clear-database-flags
You are prompted to confirm that the instance will be restarted.
REST v1
To clear all flags for an existing instance:
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
HTTP method and URL:
PATCH https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
Request JSON body:
{
  "settings":
  {
    "databaseFlags": []
  }
}
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
REST v1beta4
To clear all flags for an existing instance:
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
HTTP method and URL:
PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
Request JSON body:
{
  "settings":
  {
    "databaseFlags": []
  }
}
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
View current values of database flags
To view all current values of the PostgreSQL settings, log into your instance with thepsql client and enter the following statement:
 SELECT name, setting FROM pg_settings;
Note that you can change the value only for supported flags (as listed below).
Determine which database flags have been set for an instance
To see which flags have been set for a Cloud SQL instance:
Console
- In the Google Cloud console, select the project that contains the Cloud SQL instance for which you want to see the database flags that have been set.
- Select the instance to open its Instance Overview page.
    The database flags that have been set are listed under the Database flags section. 
gcloud
Get the instance state:
gcloud sql instances describe INSTANCE_NAME
In the output, database flags are listed under the settings as
the collection databaseFlags. For more information
  about the representation of the flags in the output, see
  Instances Resource Representation.
  
REST v1
To list flags configured for an instance:
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
HTTP method and URL:
GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
In the output, look for the databaseFlags field.
REST v1beta4
To list flags configured for an instance:
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
HTTP method and URL:
GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
In the output, look for the databaseFlags field.
Supported flags
Flags not mentioned below are not supported.
For a given flag, Cloud SQL might support a different value or range from the corresponding PostgreSQL parameter or option.
A | C | D | E | F | G | H | I | J | L | M | O | P | R | S | T | V | W
| Cloud SQL Flag | Type Acceptable Values and Notes | Restart Required? | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| anon.algorithm | StringThe default is sha256. | No | ||||||||||||||||||||
| anon.maskschema | StringThe default is mask. | No | ||||||||||||||||||||
| anon.restrict_to_trusted_schemas | booleanon|offThe default is off. | No | ||||||||||||||||||||
| anon.salt | StringThere's no default value. | No | ||||||||||||||||||||
| anon.sourceschema | StringThe default is public. | No | ||||||||||||||||||||
| auto_explain.log_analyze | booleanon|offThe default is off. | No | ||||||||||||||||||||
| auto_explain.log_buffers | booleanon|offThe default is off. | No | ||||||||||||||||||||
| auto_explain.log_min_duration | Integer-1 ... 2147483647The default is -1. | No | ||||||||||||||||||||
| auto_explain.log_format | Stringtext|xml|json|yamlThe default is text. | No | ||||||||||||||||||||
| auto_explain.log_level | Stringdebug5|debug4|debug3|debug2|debug1|debug|info|notice|warning|logThe default is log. Supported in PostgreSQL 12 and later. | No | ||||||||||||||||||||
| auto_explain.log_nested_statements | booleanon|offThe default is off. | No | ||||||||||||||||||||
| auto_explain.log_settings | booleanon|offThe default is off. Supported in PostgreSQL 12 and later. | No | ||||||||||||||||||||
| auto_explain.log_timing | booleanon|offThe default is on. | No | ||||||||||||||||||||
| auto_explain.log_triggers | booleanon|offThe default is off. | No | ||||||||||||||||||||
| auto_explain.log_wal | booleanon|offThe default is off. Supported in PostgreSQL 13 and later. | No | ||||||||||||||||||||
| auto_explain.log_verbose | booleanon|offThe default is off. | No | ||||||||||||||||||||
| auto_explain.sample_rate | Float0 ... 1The default is 1. | No | ||||||||||||||||||||
| autovacuum | booleanon|offThe default is on. For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances. | No | ||||||||||||||||||||
| autovacuum_analyze_scale_factor | float0...100The default is 0.1. | No | ||||||||||||||||||||
| autovacuum_analyze_threshold | integer0...2147483647The default is 50. | No | ||||||||||||||||||||
| autovacuum_freeze_max_age | integer100000...2000000000The default is 200000000. For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances. | Yes | ||||||||||||||||||||
| autovacuum_max_workers | integer1...varies (see note)The default is 3. | Yes | ||||||||||||||||||||
| autovacuum_multixact_freeze_max_age | integer10000...2000000000The default is 400000000. For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances. | Yes | ||||||||||||||||||||
| autovacuum_naptime | integer1...2147483sThe default is 60s. | No | ||||||||||||||||||||
| autovacuum_vacuum_cost_delay | integer0...100ms, or-1to use thevacuum_cost_delayvalueFor PostgreSQL 9.6, 10, and 11, the default value is 2 ms. | No | ||||||||||||||||||||
| autovacuum_vacuum_cost_limit | integer0... 10000, or-1to use thevacuum_cost_limitvalueThe default is -1. | No | ||||||||||||||||||||
| autovacuum_vacuum_insert_scale_factor | float0...100The default is 0.2. | No | ||||||||||||||||||||
| autovacuum_vacuum_insert_threshold | integer-1...2147483647The default is 1000. | No | ||||||||||||||||||||
| autovacuum_vacuum_max_threshold | integer-1...2147483647The default is 100000000. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| autovacuum_vacuum_scale_factor | float0...100The default is 0.2. | No | ||||||||||||||||||||
| autovacuum_vacuum_threshold | integer0...2147483647The default is 50. | No | ||||||||||||||||||||
| autovacuum_work_mem | integer0...2147483647KB, or-1to use themaintenance_work_memvalueThe default is -1. | No | ||||||||||||||||||||
| autovacuum_worker_slots | integer1...262143The default is 16. Supported in PostgreSQL 18 and later. | Yes | ||||||||||||||||||||
| backend_flush_after | integer0...256The unit is 8KB.The default is 0. | No | ||||||||||||||||||||
| bgwriter_delay | integer10...10000msThe default is 200. | No | ||||||||||||||||||||
| bgwriter_flush_after | integer0...256The unit is 8KB.The default is 64. | No | ||||||||||||||||||||
| bgwriter_lru_maxpages | integer0...1073741823The default is 100. | No | ||||||||||||||||||||
| bgwriter_lru_multiplier | Float0...10The default is 2. | No | ||||||||||||||||||||
| checkpoint_completion_target | float0.0...1.0The default is 0.9. | No | ||||||||||||||||||||
| checkpoint_flush_after | integer0...256Unit is 8KB.The default is 32. | No | ||||||||||||||||||||
| checkpoint_timeout | integer30...86,400sThe default is 300s. For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances. | No | ||||||||||||||||||||
| checkpoint_warning | integer0...2147483647sThe default is 30s. | No | ||||||||||||||||||||
| client_connection_check_interval | integer0...2147483647The default is 0. | No | ||||||||||||||||||||
| cloudsql.allow_passwordless_local_connections | booleanon|offThe default is off. | No | ||||||||||||||||||||
| cloudsql.enable_anon | booleanon|offThe default is off. | No | ||||||||||||||||||||
| cloudsql.enable_auto_explain | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_index_advisor | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_maintenance_mode | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_pgaudit | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_pg_bigm | booleanon|offdefault: off | Yes | ||||||||||||||||||||
| cloudsql.enable_pg_cron | booleanon|offThe default is off.Supported in PostgreSQL 10 and later. | Yes | ||||||||||||||||||||
| cloudsql.enable_pg_hint_plan | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_pglogical | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_pg_squeeze | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.enable_pg_wait_sampling | booleanon|off | Yes | ||||||||||||||||||||
| cloudsql.iam_authentication | booleanon|offThe default is off. | No | ||||||||||||||||||||
| cloudsql.logical_decoding | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| cloudsql.max_failed_attempts_user | integer0...10000The default is 10. | Yes | ||||||||||||||||||||
| cloudsql.pg_authid_select_role | string | No | ||||||||||||||||||||
| commit_delay | integer0...100000The default is 0. | No | ||||||||||||||||||||
| commit_siblings | integer0...1000The default is 5. | No | ||||||||||||||||||||
| constraint_exclusion | enumerationpartition|on|offThe default is partition. | No | ||||||||||||||||||||
| cpu_index_tuple_cost | float0.0...infThe default is 0.005. | No | ||||||||||||||||||||
| cpu_operator_cost | float0.0...infThe default is 0.0025. | No | ||||||||||||||||||||
| cpu_tuple_cost | float0.0...infThe default is 0.01. | No | ||||||||||||||||||||
| cron.database_name | String.Supported in PostgreSQL 10 and later. | Yes | ||||||||||||||||||||
| cron.log_statement | booleanon|offThe default is on. Supported in PostgreSQL 10 and later. | Yes | ||||||||||||||||||||
| cron.log_run | booleanon|offThe default is on. Supported in PostgreSQL 10 and later. | Yes | ||||||||||||||||||||
| cron.max_running_jobs | Integer0 ... variesThe default is 5. Supported in PostgreSQL 10 and later. | Yes | ||||||||||||||||||||
| cron.log_min_messages | Stringdebug5|debug4|debug3|debug2|debug1|debug|info|notice|warning|error|log|fatal|panicThe default is warning. Supported in PostgreSQL 10 and later. | No | ||||||||||||||||||||
| cursor_tuple_fraction | float0.0...1.0The default is 0.1. | No | ||||||||||||||||||||
| deadlock_timeout | integer1...2147483647msThe default is 1000ms. | No | ||||||||||||||||||||
| default_statistics_target | integer1...10000The default is 100. | No | ||||||||||||||||||||
| default_tablespace | string | No | ||||||||||||||||||||
| default_transaction_deferrable | booleanon|offThe default is off. | No | ||||||||||||||||||||
| default_transaction_isolation | enumerationserializable|'repeatable read'|'read committed'|'read uncommitted'The default is 'read committed'. | No | ||||||||||||||||||||
| effective_cache_size | integerThe size range is from 10% - 70% of the instance's memory. Unit is 8KB.The default is 40% of VM memory. For example, for a 45GB instance memory, the default value is 18537160KB. | No | ||||||||||||||||||||
| effective_io_concurrency | integer0...1000The default is 1. | No | ||||||||||||||||||||
| enable_async_append | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_bitmapscan | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_distinct_reordering | booleanon|offThe default is on. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| enable_gathermerge | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_incremental_sort | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_memoize | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_parallel_append | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_parallel_hash | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_partition_pruning | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_partitionwise_aggregate | booleanon|offThe default is off. | No | ||||||||||||||||||||
| enable_partitionwise_join | booleanon|offThe default is off. | No | ||||||||||||||||||||
| enable_hashagg | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_hashjoin | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_indexonlyscan | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_indexscan | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_material | booleanon|offThe default is on | No | ||||||||||||||||||||
| enable_mergejoin | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_nestloop | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_self_join_elimination | booleanon|offThe default is on. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| enable_seqscan | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_sort | booleanon|offThe default is on. | No | ||||||||||||||||||||
| enable_tidscan | booleanon|offThe default is on. | No | ||||||||||||||||||||
| force_parallel_mode | enumerationoff|on|regressThe default is off. | No | ||||||||||||||||||||
| from_collapse_limit | integer1...2147483647The default is 8. | No | ||||||||||||||||||||
| geqo | booleanon|offThe default is on. | No | ||||||||||||||||||||
| geqo_effort | integer1...10The default is 5. | No | ||||||||||||||||||||
| geqo_generations | integer0...2147483647The default is 0. | No | ||||||||||||||||||||
| geqo_pool_size | integer0...2147483647The default is 0. | No | ||||||||||||||||||||
| geqo_seed | float0.0...1.0The default is 0. | No | ||||||||||||||||||||
| geqo_selection_bias | float1.5...2.0The default is 2. | No | ||||||||||||||||||||
| geqo_threshold | integer2...2147483647The default is 12. | No | ||||||||||||||||||||
| gin_fuzzy_search_limit | integer0...2147483647The default is 0. | No | ||||||||||||||||||||
| gin_pending_list_limit | integer64...2147483647KBThe default is 4096KB. | No | ||||||||||||||||||||
| hash_mem_multiplier | float1...1000The default is 2. | No | ||||||||||||||||||||
| hot_standby_feedback | booleanon|offThe default is off. | No | ||||||||||||||||||||
| huge_pages | enumerationtry|offThe default is try. | Yes | ||||||||||||||||||||
| idle_in_transaction_session_timeout | integer0...2147483647msThe default is 0. | No | ||||||||||||||||||||
| io_max_concurrency | integer-1...1024The default is -1. Supported in PostgreSQL 18 and later. | Yes | ||||||||||||||||||||
| io_method | stringsync,workerThe default is worker. Supported in PostgreSQL 18 and later. | Yes | ||||||||||||||||||||
| io_workers | integer-1...32The default is 3. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| ivfflat.probes | integer1...variesThe default is 1. Supported in PostgreSQL 11 and later. | No | ||||||||||||||||||||
| join_collapse_limit | integer1...2147483647The default is 8. | No | ||||||||||||||||||||
| local_preload_libraries | StringThis flag lets you specify one or more shared libraries that are preloaded at the start of a database connection, in a comma-separated list. | No | ||||||||||||||||||||
| lock_timeout | integer0...2147483647msThe default is 0. | No | ||||||||||||||||||||
| log_autovacuum_min_duration | integer0...2147483647ms, or-1to disableThe default is 0. | No | ||||||||||||||||||||
| log_checkpoints | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_connections | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_disconnections | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_duration | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_error_verbosity | enumerationterse|default|verboseThe default is default. | No | ||||||||||||||||||||
| log_executor_stats | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_hostname | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_line_prefix | StringA printf-style string that's generated at the beginning of each line of a log file. The default is %m [%p]: [%l-1] db=%d,user=%u,
   which logs timestamp, process ID, database, and username. | No | ||||||||||||||||||||
| log_lock_failures | booleanon|offThe default is off. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| log_lock_waits | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_min_duration_statement | integer-1...2147483647msThe default is -1. | No | ||||||||||||||||||||
| log_min_error_statement | enumerationdebug5|debug4|debug3|debug2|debug1|info|notice|warning|error|log|fatal|panicThe default is error. | No | ||||||||||||||||||||
| log_min_messages | enumerationdebug5|debug4|debug3|debug2|debug1|info|notice|warning|error|log|fatal|panicThe default is warning. | No | ||||||||||||||||||||
| log_parser_stats | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_planner_stats | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_recovery_conflict_waits | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_replication_commands | booleanon|offThe default is off. | No | ||||||||||||||||||||
| log_statement | enumerationnone|ddl|mod|allSet to modto log all Data definition language (DDL)
      statements, plus data-modifying statements such asINSERT,UPDATE,DELETE,TRUNCATEThe default is none. | No | ||||||||||||||||||||
| log_statement_stats | booleanon|offMay not be enabled together with log_parser_stats,log_planner_stats, orlog_executor_stats.The default is off. | No | ||||||||||||||||||||
| log_temp_files | integer0...2147483647KB, or-1to disableThe default is 0. | No | ||||||||||||||||||||
| log_timezone | stringThis flag provides Cloud SQL for PostgreSQL users with a way to set the time zone used for timestamps that are written in the server log. You specify time zones by name. For example,  You must update this flag manually, on the primary instance and on all read replicas, to account for it. Timezone names are case insensitive. You can supply the timezone name in any case. We support  | Yes | ||||||||||||||||||||
| logical_decoding_work_mem | integer64...2147483647The default is 65536. | No | ||||||||||||||||||||
| maintenance_io_concurrency | integer0...1000The default is 10. | No | ||||||||||||||||||||
| maintenance_work_mem | integer1024...2147483647KBThe default is 64 MB. | No | ||||||||||||||||||||
| max_active_replication_origins | integer0...262143The default is 10 This flag must be set when using read pools. Supported in PostgreSQL 18 and later. | Yes | ||||||||||||||||||||
| max_connections | integer14...varies (see note)The default value depends on the amount of memory of the largest instance in the chain of primaries (this instance; and, if it's a read replica, its primary, its primary's primary, etc. all the way up to the root of the replication tree). 
 The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that is lower than the new value on the primary, or that have not been changed from the default value. Such changes on the primary cause the replica to restart. | Yes | ||||||||||||||||||||
| max_locks_per_transaction | integer10...2,147,483,647The default is 64. The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that is lower than the new value on the primary, or that have not been changed from the default value. Such changes on the primary cause the replica to restart. | Yes | ||||||||||||||||||||
| max_logical_replication_workers | integer4...8192The default is 4. Supported in PostgreSQL 10 and later. | Yes | ||||||||||||||||||||
| max_parallel_maintenance_workers | integer0...variesThe default is 2. Supported in PostgreSQL 11 and later. The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that's lower than the new value on the primary, or that haven't been changed from the default value. If the value on the primary is  | No | ||||||||||||||||||||
| max_parallel_workers | integer0...variesThe default is 8. Supported in PostgreSQL 10 and later. The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that's lower than the new value on the primary, or that haven't been changed from the default value. If the value on the primary is  | No | ||||||||||||||||||||
| max_parallel_workers_per_gather | integer0...variesThe default is 2. The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that's lower than the new value on the primary, or that haven't been changed from the default value. If the value on the primary is  | No | ||||||||||||||||||||
| max_pred_locks_per_page | integer0...2147483647The default is 2. Supported in PostgreSQL 10 and later. | No | ||||||||||||||||||||
| max_pred_locks_per_relation | integer-2147483648...2147483647The default is -2. Supported in PostgreSQL 10 and later. | No | ||||||||||||||||||||
| max_pred_locks_per_transaction | integer64...1048576 | Yes | ||||||||||||||||||||
| max_prepared_transactions | integer0...varies
 
 The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that is lower than the new value on the primary, or that have not been changed from the default value. Such changes on the primary cause the replica to restart. | Yes | ||||||||||||||||||||
| max_replication_slots | integer10...variesThe default is 10. | Yes | ||||||||||||||||||||
| max_standby_archive_delay | integer0...2147483647ms,
        or-1to wait forever | No | ||||||||||||||||||||
| max_standby_streaming_delay | integer0...2147483647 ms, or-1to wait forever | No | ||||||||||||||||||||
| max_sync_workers_per_subscription | integer2...64Cannot be greater than max_logical_replication_workers. | No | ||||||||||||||||||||
| max_wal_senders | integer10...variesThe default is 10. The value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that is lower than the new value on the primary, or that have not been changed from the default value. Such changes on the primary cause the replica to restart. | Yes | ||||||||||||||||||||
| max_wal_size | integer2...2147483647The unit is 16 MB (the WAL file size) for version 9.6 and 1 MB for PostgreSQL 10 and later.  The default value is  | No | ||||||||||||||||||||
| max_worker_processes | integer8...variesThe value on replicas must be greater than or equal to the value on the primary. Changes on the primary propagate to replicas that have a value that is lower than the new value on the primary, or that have not been changed from the default value. Such changes on the primary cause the replica to restart. | Yes | ||||||||||||||||||||
| min_parallel_index_scan_size | integer0...715827882Unit is 8KB | No | ||||||||||||||||||||
| min_parallel_table_scan_size | integer0...715827882Unit is 8KB | No | ||||||||||||||||||||
| min_parallel_relation_size | integer0...715827882Unit is 8KBSupported only in PostgreSQL 9.6. | No | ||||||||||||||||||||
| min_wal_size | integer32...2147483647The unit is 16 MB (the WAL file size) for version 9.6 and 1 MB for PostgreSQL 10 and later. | No | ||||||||||||||||||||
| old_snapshot_threshold | integer0...86400min, or-1to disableThe default is -1. | Yes | ||||||||||||||||||||
| parallel_setup_cost | float0.0...infThe default is 1000. | No | ||||||||||||||||||||
| parallel_tuple_cost | float0.0...infThe default is 0.1. | No | ||||||||||||||||||||
| password_encryption | enumerationmd5|scram-sha-256The default depends on the PostgreSQL version. For PostgreSQL
        versions 10 to 13, the default is  | No | ||||||||||||||||||||
| pg_bigm.enable_recheck | booleanon|off | No | ||||||||||||||||||||
| pg_bigm.gin_key_limit | integer0...2147483647 | No | ||||||||||||||||||||
| pg_bigm.similarity_limit | float0.0...1.0 | No | ||||||||||||||||||||
| pg_hint_plan.enable_hint | booleanon|offThe default is on. | No | ||||||||||||||||||||
| pg_hint_plan.debug_print | Stringoff|on|detailed|verbose|0|1||2|3|no|yes|false|trueThe default is off. | No | ||||||||||||||||||||
| pg_hint_plan.parse_messages | Stringdebug5|debug4|debug3|debug2|debug1|debug|info|notice|warning|error|logThe default is info. | No | ||||||||||||||||||||
| pg_hint_plan.message_level | Stringdebug5|debug4|debug3|debug2|debug1|debug|info|notice|warning|error|logThe default is log. | No | ||||||||||||||||||||
| pg_hint_plan.enable_hint_table | booleanon|offThe default is off. | No | ||||||||||||||||||||
| pglogical.batch_inserts | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| pglogical.conflict_log_level | StringThe default is LOG.This flag accepts the same values as log_min_messages. | No | ||||||||||||||||||||
| pglogical.conflict_resolution | Stringerror|apply_remote|keep_local|last_update_wins|first_update_wins
      The default isapply_remote. | No | ||||||||||||||||||||
| pglogical.extra_connection_options | StringAccepts PostgreSQL keyword/value connection strings. The default is the empty string. | No | ||||||||||||||||||||
| pglogical.synchronous_commit | booleanon|offThe default is on. | Yes | ||||||||||||||||||||
| pglogical.use_spi | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| pg_stat_statements.max | integer100...2147483647The default is 5000. | Yes | ||||||||||||||||||||
| pg_stat_statements.save | booleanon|offThe default is on. | No | ||||||||||||||||||||
| pg_stat_statements.track | enumerationnone|top|allThe default is top. | No | ||||||||||||||||||||
| pg_stat_statements.track_utility | booleanon|offThe default is on. | No | ||||||||||||||||||||
| pgaudit.log | enumerationread|write|function|role|ddl|misc|misc_set|all|noneYou can provide multiple classes using a comma-separated list, and
        subtract a class by prefacing the class with
        a  | No | ||||||||||||||||||||
| pgaudit.log_catalog | booleanon|offThe default is on. | No | ||||||||||||||||||||
| pgaudit.log_client | booleanon|offThe default is off. | No | ||||||||||||||||||||
| pgaudit.log_level | enumerationdebug5|debug4|debug3|debug2|debug1|info|notice|warning|error|logThe default is log. Additionally,pgaudit.log_levelis enabled only whenpgaudit.log_clientis on. | No | ||||||||||||||||||||
| pgaudit.log_parameter | booleanon|offThe default is off. | No | ||||||||||||||||||||
| pgaudit.log_relation | booleanon|offThe default is off. | No | ||||||||||||||||||||
| pgaudit.log_statement_once | booleanon|offThe default is off. | No | ||||||||||||||||||||
| pgaudit.role | stringThere is no default. | No | ||||||||||||||||||||
| pgaudit.log_rows | booleanThe default is off. | No | ||||||||||||||||||||
| pgtt.enabled | booleanon|offThe default is on. | No | ||||||||||||||||||||
| pg_wait_sampling.history_period | integer1...2147483647 | No | ||||||||||||||||||||
| pg_wait_sampling.history_size | integer1...2147483647 | No | ||||||||||||||||||||
| pg_wait_sampling.profile_period | integer1...2147483647 | No | ||||||||||||||||||||
| pg_wait_sampling.profile_pid | booleanon|off | No | ||||||||||||||||||||
| pg_wait_sampling.profile_queries | booleanon|off | No | ||||||||||||||||||||
| random_page_cost | float0.0...infThe default is 4. | No | ||||||||||||||||||||
| plan_cache_mode | Stringauto|force_generic_plan|force_custom_planThe default is auto. | No | ||||||||||||||||||||
| rdkit.agent_FP_bit_ratio | float0...3 | No | ||||||||||||||||||||
| rdkit.avalon_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.dice_threshold | float0...1 | No | ||||||||||||||||||||
| rdkit.difference_FP_weight_agents | integer-10...10 | No | ||||||||||||||||||||
| rdkit.difference_FP_weight_nonagents | integer1...20 | No | ||||||||||||||||||||
| rdkit.do_chiral_sss | booleanon|off | No | ||||||||||||||||||||
| rdkit.do_enhanced_stereo_sss | booleanon|off | No | ||||||||||||||||||||
| rdkit.featmorgan_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.hashed_atompair_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.hashed_torsion_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.ignore_reaction_agents | booleanon|off | No | ||||||||||||||||||||
| rdkit.init_reaction | booleanon|off | No | ||||||||||||||||||||
| rdkit.layered_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.morgan_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.move_unmmapped_reactants_to_agents | booleanon|off | No | ||||||||||||||||||||
| rdkit.rdkit_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.reaction_difference_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.reaction_difference_fp_type | integer1...3 | No | ||||||||||||||||||||
| rdkit.reaction_sss_fp_size | integer64...9192 | No | ||||||||||||||||||||
| rdkit.reaction_sss_fp_type | integer1...5 | No | ||||||||||||||||||||
| rdkit.sss_fp_size | integer64...4096 | No | ||||||||||||||||||||
| rdkit.tanimoto_threshold | float0...1 | No | ||||||||||||||||||||
| rdkit.threshold_unmapped_reactant_atoms | float0...1 | No | ||||||||||||||||||||
| replacement_sort_tuples | integer0...2147483647 | No | ||||||||||||||||||||
| session_replication_role | enumerationorigin|replica|localCan be set only in current session | - | ||||||||||||||||||||
| seq_page_cost | float0.0...infThe default is 1.0. | No | ||||||||||||||||||||
| shared_buffers | integerThe size range is from 10% - 60% of the instance's memory. Unit is 8KB.The default is one-third of the instance's total VM memory (in MB). For example, for 45GB of instance memory, the default value is15085MB. | Yes | ||||||||||||||||||||
| squeeze.max_xlock_time | integer1...2147483647 | No | ||||||||||||||||||||
| squeeze.worker_autostart | string | Yes | ||||||||||||||||||||
| squeeze.worker_role | string | Yes | ||||||||||||||||||||
| ssl_max_protocol_version | enumerationPostgres 14: Sets the maximum SSL/TLS protocol version to use. Valid values are as for ssl_min_protocol_version, with the addition of an empty string,
       which allows any protocol version to be specified.Supported in PostgreSQL 12 and later. | No | ||||||||||||||||||||
| ssl_min_protocol_version | enumerationPostgres 14: Sets the minimum SSL/TLS protocol version to use. Valid values are currently: TLSv1,TLSv1.1,TLSv1.2,TLSv1.3.The default is TLSv1.Supported in PostgreSQL 12 and later. | No | ||||||||||||||||||||
| standard_conforming_strings | booleanon|offThe default is on. | No | ||||||||||||||||||||
| synchronize_seqscans | booleanon|offThe default is on. | No | ||||||||||||||||||||
| tcp_keepalives_count | integer0...2147483647The default is 5. | No | ||||||||||||||||||||
| tcp_keepalives_idle | integer0...2147483647The default is 60. | No | ||||||||||||||||||||
| tcp_keepalives_interval | integer0...2147483647The default is 60. | No | ||||||||||||||||||||
| temp_buffers | integer100...1,073,741,823Unit is 8KB | No | ||||||||||||||||||||
| temp_file_limit | integer1048576...2147483647KBThe default is 10% of the initial disk size. For example, for a 100-GB disk, the default value is 10262623KB. | No | ||||||||||||||||||||
| TimeZone | stringThis flag provides Cloud SQL for PostgreSQL users with a way to set the time zone for displaying and analyzing timestamps. You specify time zones by name. For example,  You must update this flag manually, on the primary instance and on all read replicas, to account for it. Timezone names are case insensitive. You can supply the timezone name in any case. We support  | Yes | ||||||||||||||||||||
| trace_notify | booleanon|offThe default is off. | No | ||||||||||||||||||||
| trace_recovery_messages | enumerationdebug5|debug4|debug3|debug2|debug1|log|notice|warning|errorThe default is log. | No | ||||||||||||||||||||
| trace_sort | booleanon|offThe default is off. | No | ||||||||||||||||||||
| track_activities | booleanon|offThe default is on. | No | ||||||||||||||||||||
| track_activity_query_size | integer100...102400The default is 1 KB. | Yes | ||||||||||||||||||||
| track_commit_timestamp | booleanon|offThe default is off. | Yes | ||||||||||||||||||||
| track_cost_delay_timing | booleanon|offThe default is off. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| track_counts | booleanon|offThe default is on. | No | ||||||||||||||||||||
| track_functions | enumerationnone|pl|allThe default is none. | No | ||||||||||||||||||||
| track_io_timing | booleanon|offThe default is off. | No | ||||||||||||||||||||
| vacuum_cost_delay | integer0...100msThe default is 0. | No | ||||||||||||||||||||
| vacuum_cost_limit | integer1...10000The default is 200. | No | ||||||||||||||||||||
| vacuum_cost_page_dirty | integer0...10000The default is 20. | No | ||||||||||||||||||||
| vacuum_cost_page_hit | integer0...10000The default is 1. | No | ||||||||||||||||||||
| vacuum_cost_page_miss | integer0...10000The default is 10. | No | ||||||||||||||||||||
| vacuum_failsafe_age | integer0...2100000000The default is 1600000000. | No | ||||||||||||||||||||
| vacuum_freeze_min_age | integer0...1000000000The default is 50000000. | No | ||||||||||||||||||||
| vacuum_freeze_table_age | integer0...2000000000The default is 150000000. | No | ||||||||||||||||||||
| vacuum_max_eager_freeze_failure_rate | float0...1The default is 0.03. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| vacuum_multixact_failsafe_age | integer0...2100000000The default is 1600000000. | No | ||||||||||||||||||||
| vacuum_multixact_freeze_min_age | integer0...1000000000The default is 5000000. | No | ||||||||||||||||||||
| vacuum_multixact_freeze_table_age | integer0...2000000000The default is 150000000. | No | ||||||||||||||||||||
| vacuum_truncate | booleanon|offThe default is on. Supported in PostgreSQL 18 and later. | No | ||||||||||||||||||||
| wal_buffers | integerThe size range is from -1 - 5% of the instance's memory. Unit is 8KB.The default is 16 MB. | Yes | ||||||||||||||||||||
| wal_compression | enumerationoff|on|pglz|lz4|zstdThe default is off. | No | ||||||||||||||||||||
| wal_receiver_timeout | integer0...2147483647The default is 60 seconds. This flag affects the WAL sender and receiver. If not appropriately set, this flag affects logical and physical replication. This flag also affects replication performance and latency. A value of zero disables the timeout mechanism. The unit is milliseconds. | No | ||||||||||||||||||||
| wal_sender_timeout | integer0...2147483647The default is 60 seconds. This flag affects the WAL sender and receiver. If not appropriately set, this flag affects logical and physical replication. This flag also affects replication performance and latency. A value of zero disables the timeout mechanism. The unit is milliseconds. | No | ||||||||||||||||||||
| wal_writer_delay | integer1...10000The default is 200. | No | ||||||||||||||||||||
| wal_writer_flush_after | integer0...2147483647The default is 128. | No | ||||||||||||||||||||
| work_mem | integer64...2147483647KBThe default is 4 MB. | No | 
Special flags
bgwriter
PostgreSQL has a background writer (bgwriter) flag. This flag issues writes of
new or modified shared buffers. These shared buffers are known as dirty buffers.
When the number of clean shared buffers is insufficient, the background writer
writes dirty buffers to the file system and marks them as clean.
Two flags associated with the bgwriter flag are bgwriter_delay and bgwriter_lru_maxpages. bgwriter_delay specifies the delay between activity
rounds for the background writer in milliseconds (ms), and bgwriter_lru_maxpages
specifies how many buffers will be written by the background writer.
The default value for the bgwriter flag is 200 ms. However, if
you select a solid state drive (SSD) that's greater than 500 GB, then the value
of the bgwriter_delay flag is set to 50, and the value of
the bgwriter_lru_maxpages flag is set to 200.
For more information about the background writer, see the PostgreSQL documentation.
session_replication_role
PostgreSQL has the session_replication_role flag, which is designed to be used
for logical replication and lets you disable constraint triggers in
individual sessions.
Sometimes this flag can also be used for some maintenance operations to circumvent constraint (most often Foreign Key) checks.
This flag can be set in a session by any user which has the REPLICATION
property set. The REPLICATION property for any user can be set by
cloudsqlsuperuser when one of flags
cloudsql.enable_pglogical or
cloudsql.logical_decoding is set for the instance.
This flag can not be set for the whole instance.
Troubleshooting
| Issue | Troubleshooting | 
|---|---|
| You set the time zone for a session, but it expires when you log off. | Connect to the database and set the database time zone to the one you want, either per user or per database. In Cloud SQL for PostgreSQL, you can specify the following.
    These settings remain after a session is closed, mimicking a
     ALTER DATABASE dbname SET TIMEZONE TO 'timezone'; ALTER USER username SET TIMEZONE TO 'timezone'; These settings apply only to new connections to the database. To see the change to the time zone, disconnect from the instance and then reconnect to it. | 
What's next
- Learn more about PostgreSQL server configuration.
- Learn more about Operational Guidelines.