Configure database flags

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 desired functionality.

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

Set a database flag

Console

  1. In the Google Cloud console, select the project that contains the Cloud SQL instance for which you want to set a database flag.
  2. Open the instance and click Edit.
  3. Scroll down to the Flags section.
  4. 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.
  5. Click Save to save your changes.
  6. Confirm your changes under Flags on the Overview page.

gcloud

Edit the instance:

gcloudsqlinstancespatchINSTANCE_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 do not 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:

gcloudsqlinstancespatchINSTANCE_NAME\--database-flags=log_connections=on,log_min_error_statement=error

Terraform

To add database flags, use a Terraform resource.

resource "google_sql_database_instance" "instance" { name = "postgres-instance" region = "us-central1" database_version = "POSTGRES_14" settings { database_flags { name = "log_connections" value = "on" } database_flags { name = "log_min_error_statement" value = "error" } tier = "db-custom-2-7680" } # set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by # use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level. deletion_protection = false }

Apply the changes

To apply your Terraform configuration in a Google Cloud project, complete the steps in the following sections.

Prepare Cloud Shell

  1. Launch Cloud Shell.
  2. 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).

  1. In Cloud Shell, create a directory and a new file within that directory. The filename must have the .tf extension—for example main.tf. In this tutorial, the file is referred to as main.tf.
    mkdir DIRECTORY && cd DIRECTORY && touch main.tf
  2. 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.

  3. Review and modify the sample parameters to apply to your environment.
  4. Save your changes.
  5. Initialize Terraform. You only need to do this once per directory.
    terraform init

    Optionally, to use the latest Google provider version, include the -upgrade option:

    terraform init -upgrade

Apply the changes

  1. 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.

  2. Apply the Terraform configuration by running the following command and entering yes at the prompt:
    terraform apply

    Wait until Terraform displays the "Apply complete!" message.

  3. 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:

  1. To disable deletion protection, in your Terraform configuration file set the deletion_protection argument to false.
    deletion_protection = "false"
  2. Apply the updated Terraform configuration by running the following command and entering yes at the prompt:
    terraform apply
  1. Remove resources previously applied with your Terraform configuration by running the following command and entering yes at 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

  1. In the Google Cloud console, select the project that contains the Cloud SQL instance for which you want to clear all flags.
  2. Open the instance and click Edit.
  3. Open the Database flags section.
  4. Click the X next to all of the flags shown.
  5. Click Save to save your changes.

gcloud

Clear all flags to their default values on an instance:

gcloudsqlinstancespatchINSTANCE_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 the psql client and enter the following statement:

SELECTname,settingFROMpg_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

  1. 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.
  2. 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:

gcloudsqlinstancesdescribeINSTANCE_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 FlagType
Acceptable Values and Notes
Restart
Required?
anon.algorithmString
The default is sha256.
No
anon.maskschemaString
The default is mask.
No
anon.restrict_to_trusted_schemasboolean
on | off
The default is off.
No
anon.saltString
There's no default value.
No
anon.sourceshemaString
The default is public.
No
auto_explain.log_analyzeboolean
on | off
The default is off.
No
auto_explain.log_buffersboolean
on | off
The default is off.
No
auto_explain.log_min_durationInteger
-1 ... 2147483647
The default is -1.
No
auto_explain.log_formatString
text|xml|json|yaml
The default is text.
No
auto_explain.log_levelString
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|log
The default is log.
Supported in PostgreSQL 12 and above.
No
auto_explain.log_nested_statementsboolean
on | off
The default is off.
No
auto_explain.log_settingsboolean
on | off
The default is off.
Supported in PostgreSQL 12 and above.
No
auto_explain.log_timingboolean
on | off
The default is on.
No
auto_explain.log_triggersboolean
on | off
The default is off.
No
auto_explain.log_walboolean
on | off
The default is off.
Supported in PostgreSQL 13 and above.
No
auto_explain.log_verboseboolean
on | off
The default is off.
No
auto_explain.sample_rateFloat
0 ... 1
The default is 1.
No
autovacuumboolean
on | off
The 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_factorfloat
0 ... 100
The default is 0.1.
No
autovacuum_analyze_thresholdinteger
0 ... 2147483647
The default is 50.
No
autovacuum_freeze_max_ageinteger
100000 ... 2000000000
The default is 200000000.
For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances.
Yes
autovacuum_max_workersinteger
1 ... varies (see note)
The default is 3.
Yes
autovacuum_multixact_freeze_max_ageinteger
10000 ... 2000000000
The default is 400000000.
For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances.
Yes
autovacuum_naptimeinteger
1 ... 2147483s
The default is 60s.
No
autovacuum_vacuum_cost_delayinteger
0 ... 100 ms, or -1 to use the vacuum_cost_delay value
For PostgreSQL 9.6, 10, and 11, the default value is 2 ms.
No
autovacuum_vacuum_cost_limitinteger
0 ... 10000, or -1 to use the vacuum_cost_limit value
The default is -1.
No
autovacuum_vacuum_insert_scale_factorfloat
0 ... 100
The default is 0.2.
No
autovacuum_vacuum_insert_thresholdinteger
-1 ... 2147483647
The default is 1000.
No
autovacuum_vacuum_scale_factorfloat
0 ... 100
The default is 0.2.
No
autovacuum_vacuum_thresholdinteger
0 ... 2147483647
The default is 50.
No
autovacuum_work_meminteger
0 ... 2147483647 KB, or -1 to use the maintenance_work_mem value
The default is -1.
No
backend_flush_afterinteger
0 ... 256
The unit is 8 KB.
The default is 0.
No
bgwriter_delayinteger
10 ... 10000 ms
The default is 200.
No
bgwriter_flush_afterinteger
0 ... 256
The unit is 8 KB.
The default is 64.
No
bgwriter_lru_maxpagesinteger
0 ... 1073741823
The default is 100.
No
bgwriter_lru_multiplierFloat
0 ... 10
The default is 2.
No
checkpoint_completion_targetfloat
0.0 ... 1.0
The default is 0.9.
No
checkpoint_flush_afterinteger
0 ... 256
Unit is 8 KB.
The default is 32.
No
checkpoint_timeoutinteger
30 ... 86,400s
The default is 300s.
For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances.
No
checkpoint_warninginteger
0 ... 2147483647s
The default is 30s.
No
client_connection_check_intervalinteger
0 ... 2147483647
The default is 0.
No
cloudsql.allow_passwordless_local_connectionsboolean
on | off
The default is off.
No
cloudsql.enable_anonboolean
on | off
The default is off.
No
cloudsql.enable_auto_explainboolean
on | off
The default is off.
Yes
cloudsql.enable_index_advisorboolean
on | off
The default is off.
Yes
cloudsql.enable_maintenance_modeboolean
on | off
The default is off.
Yes
cloudsql.enable_pgauditboolean
on | off
The default is off.
Yes
cloudsql.enable_pg_bigmboolean
on | off
default: off
Yes
cloudsql.enable_pg_cronboolean
on | off
The default is off.
Supported in PostgreSQL 10 and above.
Yes
cloudsql.enable_pg_hint_planboolean
on | off
The default is off.
Yes
cloudsql.enable_pglogicalboolean
on | off
The default is off.
Yes
cloudsql.enable_pg_squeezeboolean
on | off
The default is off.
Yes
cloudsql.enable_pg_wait_samplingboolean
on | off
Yes
cloudsql.iam_authenticationboolean
on | off
The default is off.
No
cloudsql.logical_decodingboolean
on | off
The default is off.
Yes
cloudsql.max_failed_attempts_userinteger
0 ... 10000
The default is 10.
Yes
cloudsql.pg_authid_select_rolestring
No
commit_delayinteger
0 ... 100000
The default is 0.
No
commit_siblingsinteger
0 ... 1000
The default is 5.
No
constraint_exclusionenumeration
partition | on | off
The default is partition.
No
cpu_index_tuple_costfloat
0.0 ... inf
The default is 0.005.
No
cpu_operator_costfloat
0.0 ... inf
The default is 0.0025.
No
cpu_tuple_costfloat
0.0 ... inf
The default is 0.01.
No
cron.database_nameString.
Supported in PostgreSQL 10 and above.
Yes
cron.log_statementboolean
on | off
The default is on.
Supported in PostgreSQL 10 and above.
Yes
cron.log_runboolean
on | off
The default is on.
Supported in PostgreSQL 10 and above.
Yes
cron.max_running_jobsInteger
0 ... varies
The default is 5.
Supported in PostgreSQL 10 and above.
Yes
cron.log_min_messagesString
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|error|log|fatal|panic
The default is warning.
Supported in PostgreSQL 10 and above.
No
cursor_tuple_fractionfloat
0.0 ... 1.0
The default is 0.1.
No
deadlock_timeoutinteger
1 ... 2147483647 ms
The default is 1000ms.
No
default_statistics_targetinteger
1 ... 10000
The default is 100.
No
default_tablespacestringNo
default_transaction_deferrableboolean
on | off
The default is off.
No
default_transaction_isolationenumeration
serializable | 'repeatable read' | 'read committed' | 'read uncommitted'
The default is 'read committed'.
No
effective_cache_sizeinteger
The size range is from 10% - 70% of the instance's memory.
Unit is 8 KB.
The default is 40% of VM memory. For example, for a 45GB instance memory, the default value is 18537160 KB.
No
effective_io_concurrencyinteger
0 ... 1000
The default is 1.
No
enable_async_appendboolean
on | off
The default is on.
No
enable_bitmapscanboolean
on | off
The default is on.
No
enable_gathermergeboolean
on | off
The default is on.
No
enable_incremental_sortboolean
on | off
The default is on.
No
enable_memoizeboolean
on | off
The default is on.
No
enable_parallel_appendboolean
on | off
The default is on.
No
enable_parallel_hashboolean
on | off
The default is on.
No
enable_partition_pruningboolean
on | off
The default is on.
No
enable_partitionwise_aggregateboolean
on | off
The default is off.
No
enable_partitionwise_joinboolean
on | off
The default is off.
No
enable_hashaggboolean
on | off
The default is on.
No
enable_hashjoinboolean
on | off
The default is on.
No
enable_indexonlyscanboolean
on | off
The default is on.
No
enable_indexscanboolean
on | off
The default is on.
No
enable_materialboolean
on | off
The default is on
No
enable_mergejoinboolean
on | off
The default is on.
No
enable_nestloopboolean
on | off
The default is on.
No
enable_seqscanboolean
on | off
The default is on.
No
enable_sortboolean
on | off
The default is on.
No
enable_tidscanboolean
on | off
The default is on.
No
force_parallel_modeenumeration
off | on | regress
The default is off.
No
from_collapse_limitinteger
1 ... 2147483647
The default is 8.
No
geqoboolean
on | off
The default is on.
No
geqo_effortinteger
1 ... 10
The default is 5.
No
geqo_generationsinteger
0 ... 2147483647
The default is 0.
No
geqo_pool_sizeinteger
0 ... 2147483647
The default is 0.
No
geqo_seedfloat
0.0 ... 1.0
The default is 0.
No
geqo_selection_biasfloat
1.5 ... 2.0
The default is 2.
No
geqo_thresholdinteger
2 ... 2147483647
The default is 12.
No
gin_fuzzy_search_limitinteger
0 ... 2147483647
The default is 0.
No
gin_pending_list_limitinteger
64 ... 2147483647KB
The default is 4096KB.
No
hash_mem_multiplierfloat
1 ... 1000
The default is 2.
No
hot_standby_feedbackboolean
on | off
The default is off.
No
huge_pagesenumeration
try | off
The default is try.
Yes
idle_in_transaction_session_timeoutinteger
0 ... 2147483647 ms
The default is 0.
No
ivfflat.probesinteger
1 ... varies
The default is 1.
Supported in PostgreSQL 11 and above.
No
join_collapse_limitinteger
1 ... 2147483647
The default is 8.
No
lock_timeoutinteger
0 ... 2147483647 ms
The default is 0.
No
log_autovacuum_min_durationinteger
0 ... 2147483647 ms, or -1 to disable
The default is 0.
No
log_checkpointsboolean
on | off
The default is off.
No
log_connectionsboolean
on | off
The default is off.
No
log_disconnectionsboolean
on | off
The default is off.
No
log_durationboolean
on | off
The default is off.
No
log_error_verbosityenumeration
terse | default | verbose
The default is default.
No
log_executor_statsboolean
on | off
The default is off.
No
log_hostnameboolean
on | off
The default is off.
No
log_line_prefixString
A 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_waitsboolean
on | off
The default is off.
No
log_min_duration_statementinteger
-1 ... 2147483647 ms
The default is -1.
No
log_min_error_statementenumeration
debug5 | debug4 | debug3 | debug2 | debug1 | info | notice | warning | error | log | fatal | panic
The default is error.
No
log_min_messagesenumeration
debug5 | debug4 | debug3 | debug2 | debug1 | info | notice | warning | error | log | fatal | panic
The default is warning.
No
log_parser_statsboolean
on | off
The default is off.
No
log_planner_statsboolean
on | off
The default is off.
No
log_recovery_conflict_waitsboolean
on | off
The default is off.
No
log_replication_commandsboolean
on | off
The default is off.
No
log_statementenumeration
none | ddl | mod | all
Set to mod to log all Data definition language (DDL) statements, plus data-modifying statements such as INSERT, UPDATE, DELETE, TRUNCATE
The default is none.
No
log_statement_statsboolean
on | off
May not be enabled together with log_parser_stats, log_planner_stats, or log_executor_stats.
The default is off.
No
log_temp_filesinteger
0 ... 2147483647 KB, or -1 to disable
The default is 0.
No
log_timezonestring
This 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, Europe/London is the timezone name for London.

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 UTC+X as a valid format for this flag, where X is +/-HH:MM.

Yes
logical_decoding_work_meminteger
64 ... 2147483647
The default is 65536.
No
maintenance_io_concurrencyinteger
0 ... 1000
The default is 10.
No
maintenance_work_meminteger
1024 ... 2147483647 KB
The default is 64 MB.
No
max_connectionsinteger
14 ... 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).
Memory (GB) on largest instanceDefault value
tiny (~0.5)25
small (~1.7)50
from 3.75 to < 6100
from 6 to < 7.5200
from 7.5 to < 15400
from 15 to < 30500
from 30 to < 60600
from 60 to < 120800
>=1201,000

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_transactioninteger
10 ... 2,147,483,647
The 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_workersinteger
4 ... 8192
The default is 4.
Supported in PostgreSQL 10 and above.
Yes
max_parallel_maintenance_workersinteger
0 ... varies
The default is 2.
Supported in PostgreSQL 11 and above.

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 default, then the value for the replicas can't be changed. To change the value for the replicas, first, set the value on the primary to an integer.

No
max_parallel_workersinteger
0 ... varies
The default is 8.
Supported in PostgreSQL 10 and above.

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 default, then the value for the replicas can't be changed. To change the value for the replicas, first, set the value on the primary to an integer.

No
max_parallel_workers_per_gatherinteger
0 ... varies
The 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 default, then the value for the replicas can't be changed. To change the value for the replicas, first, set the value on the primary to an integer.

No
max_pred_locks_per_pageinteger
0 ... 2147483647
The default is 2.
Supported in PostgreSQL 10 and above.
No
max_pred_locks_per_relationinteger
-2147483648 ... 2147483647
The default is -2.
Supported in PostgreSQL 10 and above.
No
max_pred_locks_per_transactioninteger
64 ... 1048576
Yes
max_prepared_transactionsinteger
0 ... varies
Memory size (MB)Max value
0 - 3,84030,000
3,840 - 7,68085,000
7,680 - 15,360200,000
15,360 and above262,000

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_slotsinteger
10 ... varies
The default is 10.
Yes
max_standby_archive_delayinteger
0 ... 2147483647 ms, or -1 to wait forever
No
max_standby_streaming_delayinteger
0 ... 2147483647 ms, or -1 to wait forever
No
max_sync_workers_per_subscriptioninteger
2 ... 64
Cannot be greater than max_logical_replication_workers.
No
max_wal_sendersinteger
10 ... varies
The 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_sizeinteger
2 ... 2147483647

The unit is 16 MB (the WAL file size) for version 9.6 and 1 MB for PostgreSQL 10 and above.

The default value is 1504 MB if instance memory more than or equal to 3.75 GB. The default value is 1 GB if instance memory is less than 3.75 GB.

For usage information that might affect the SLA, see the Operational guidelines for Cloud SQL for PostgreSQL instances.
No
max_worker_processesinteger
8 ... 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
min_parallel_index_scan_sizeinteger
0 ... 715827882
Unit is 8 KB
No
min_parallel_table_scan_sizeinteger
0 ... 715827882
Unit is 8 KB
No
min_parallel_relation_sizeinteger
0 ... 715827882
Unit is 8 KB
Supported only in PostgreSQL 9.6.
No
min_wal_sizeinteger
32 ... 2147483647

The unit is 16 MB (the WAL file size) for version 9.6 and 1 MB for PostgreSQL 10 and above.

No
old_snapshot_thresholdinteger
0 ... 86400 min, or -1 to disable
The default is -1.
Yes
parallel_setup_costfloat
0.0 ... inf
The default is 1000.
No
parallel_tuple_costfloat
0.0 ... inf
The default is 0.1.
No
password_encryptionenumeration
md5 | scram-sha-256

The default depends on the PostgreSQL version. For PostgreSQL versions 10 to 13, the default is md5. For PostgreSQL 14 and higher, the default is scram-sha-256.

No
pg_bigm.enable_recheckboolean
on | off
No
pg_bigm.gin_key_limitinteger
0 ... 2147483647
No
pg_bigm.similarity_limitfloat
0.0 ... 1.0
No
pg_hint_plan.enable_hintboolean
on | off
The default is on.
No
pg_hint_plan.debug_printString
off|on|detailed|verbose|0|1||2|3|no|yes|false|true
The default is off.
No
pg_hint_plan.parse_messagesString
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|error|log
The default is info.
No
pg_hint_plan.message_levelString
debug5|debug4|debug3|debug2|debug1|debug|
info|notice|warning|error|log
The default is log.
No
pg_hint_plan.enable_hint_tableboolean
on | off
The default is off.
No
pglogical.batch_insertsboolean
on | off
The default is off.
Yes
pglogical.conflict_log_levelString
The default is LOG.
This flag accepts the same values as log_min_messages.
No
pglogical.conflict_resolutionString
error|apply_remote|keep_local|last_update_wins|first_update_wins The default is apply_remote.
No
pglogical.extra_connection_optionsString
Accepts PostgreSQL keyword/value connection strings.
The default is the empty string.
No
pglogical.synchronous_commitboolean
on | off
The default is on.
Yes
pglogical.use_spiboolean
on | off
The default is off.
Yes
pg_stat_statements.maxinteger
100 ... 2147483647
The default is 5000.
Yes
pg_stat_statements.saveboolean
on | off
The default is on.
No
pg_stat_statements.trackenumeration
none | top | all
The default is top.
No
pg_stat_statements.track_utilityboolean
on | off
The default is on.
No
pgaudit.logenumeration
read | write | function | role | ddl | misc | misc_set | all|none

You can provide multiple classes using a comma-separated list, and subtract a class by prefacing the class with a - sign. The default is none.

No
pgaudit.log_catalogboolean
on | off
The default is on.
No
pgaudit.log_clientboolean
on | off
The default is off.
No
pgaudit.log_levelenumeration
debug5 | debug4 | debug3 | debug2 | debug1 | info | notice | warning | error | log
The default is log. Additionally, pgaudit.log_level is enabled only when pgaudit.log_client is on.
No
pgaudit.log_parameterboolean
on | off
The default is off.
No
pgaudit.log_relationboolean
on | off
The default is off.
No
pgaudit.log_statement_onceboolean
on | off
The default is off.
No
pgaudit.rolestring
There is no default.
No
pgtt.enabledboolean
on | off
The default is on.
No
pg_wait_sampling.history_periodinteger
1 ... 2147483647
No
pg_wait_sampling.history_sizeinteger
1 ... 2147483647
No
pg_wait_sampling.profile_periodinteger
1 ... 2147483647
No
pg_wait_sampling.profile_pidboolean
on | off
No
pg_wait_sampling.profile_queriesboolean
on | off
No
random_page_costfloat
0.0 ... inf
The default is 4.
No
plan_cache_mode

String
auto|force_generic_plan|force_custom_plan
The default is auto.
No
rdkit.agent_FP_bit_ratiofloat
0 ... 3
No
rdkit.avalon_fp_sizeinteger
64 ... 9192
No
rdkit.dice_thresholdfloat
0 ... 1
No
rdkit.difference_FP_weight_agentsinteger
-10 ... 10
No
rdkit.difference_FP_weight_nonagentsinteger
1 ... 20
No
rdkit.do_chiral_sssboolean
on | off
No
rdkit.do_enhanced_stereo_sssboolean
on | off
No
rdkit.featmorgan_fp_sizeinteger
64 ... 9192
No
rdkit.hashed_atompair_fp_sizeinteger
64 ... 9192
No
rdkit.hashed_torsion_fp_sizeinteger
64 ... 9192
No
rdkit.ignore_reaction_agentsboolean
on | off
No
rdkit.init_reactionboolean
on | off
No
rdkit.layered_fp_sizeinteger
64 ... 9192
No
rdkit.morgan_fp_sizeinteger
64 ... 9192
No
rdkit.move_unmmapped_reactants_to_agentsboolean
on | off
No
rdkit.rdkit_fp_sizeinteger
64 ... 9192
No
rdkit.reaction_difference_fp_sizeinteger
64 ... 9192
No
rdkit.reaction_difference_fp_typeinteger
1 ... 3
No
rdkit.reaction_sss_fp_sizeinteger
64 ... 9192
No
rdkit.reaction_sss_fp_typeinteger
1 ... 5
No
rdkit.sss_fp_sizeinteger
64 ... 4096
No
rdkit.tanimoto_thresholdfloat
0 ... 1
No
rdkit.threshold_unmapped_reactant_atomsfloat
0 ... 1
No
replacement_sort_tuplesinteger
0 ... 2147483647
No
session_replication_roleenumeration
origin | replica | local
Can be set only in current session
-
seq_page_costfloat
0.0 ... inf
The default is 1.0.
No
shared_buffersinteger
The size range is from 10% - 60% of the instance's memory.
Unit is 8 KB.
The default is one-third of the instance's total VM memory (in MB). For example, for 45 GB of instance memory, the default value is 15085MB.
Yes
squeeze.max_xlock_timeinteger
1 ... 2147483647
No
squeeze.worker_autostartstring
Yes
squeeze.worker_rolestring
Yes
ssl_max_protocol_versionenumeration
Postgres 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 above.
No
ssl_min_protocol_versionenumeration
Postgres 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 above.
No
standard_conforming_stringsboolean
on | off
The default is on.
No
synchronize_seqscansboolean
on | off
The default is on.
No
tcp_keepalives_countinteger
0 ... 2147483647
The default is 5.
No
tcp_keepalives_idleinteger
0 ... 2147483647
The default is 60.
No
tcp_keepalives_intervalinteger
0 ... 2147483647
The default is 60.
No
temp_buffersinteger
100 ... 1,073,741,823
Unit is 8 KB
No
temp_file_limitinteger
1048576 ... 2147483647 KB
The default is 10% of the initial disk size. For example, for a 100-GB disk, the default value is 10262623KB.
No
TimeZonestring
This 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, Europe/London is the timezone name for London.

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 UTC+X as a valid format for this flag, where X is +/-HH.

Yes
trace_notifyboolean
on | off
The default is off.
No
trace_recovery_messagesenumeration
debug5 | debug4 | debug3 | debug2 | debug1 | log | notice | warning | error
The default is log.
No
trace_sortboolean
on | off
The default is off.
No
track_activitiesboolean
on | off
The default is on.
No
track_activity_query_sizeinteger
100 ... 102400
The default is 1 KB.
Yes
track_commit_timestampboolean
on | off
The default is off.
Yes
track_countsboolean
on | off
The default is on.
No
track_functionsenumeration
none | pl | all
The default is none.
No
track_io_timingboolean
on | off
The default is off.
No
vacuum_cost_delayinteger
0 ... 100 ms
The default is 0.
No
vacuum_cost_limitinteger
1 ... 10000
The default is 200.
No
vacuum_cost_page_dirtyinteger
0 ... 10000
The default is 20.
No
vacuum_cost_page_hitinteger
0 ... 10000
The default is 1.
No
vacuum_cost_page_missinteger
0 ... 10000
The default is 10.
No
vacuum_failsafe_ageinteger
0 ... 2100000000
The default is 1600000000.
No
vacuum_freeze_min_ageinteger
0 ... 1000000000
The default is 50000000.
No
vacuum_freeze_table_ageinteger
0 ... 2000000000
The default is 150000000.
No
vacuum_multixact_failsafe_ageinteger
0 ... 2100000000
The default is 1600000000.
No
vacuum_multixact_freeze_min_ageinteger
0 ... 1000000000
The default is 5000000.
No
vacuum_multixact_freeze_table_ageinteger
0 ... 2000000000
The default is 150000000.
No
wal_buffersinteger
The size range is from -1 - 5% of the instance's memory.
Unit is 8 KB.
The default is 16 MB.
Yes
wal_compressionenumeration
off | on | pglz | lz4 | zstd
The default is off.
No
wal_receiver_timeoutinteger
0 ... 2147483647
The 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_timeoutinteger
0 ... 2147483647
The 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_delayinteger
1 ... 10000
The default is 200.
No
wal_writer_flush_afterinteger
0 ... 2147483647
The default is 128.
No
work_meminteger
64 ... 2147483647 KB
The 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

IssueTroubleshooting
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 .conf configuration:

ALTERDATABASEdbnameSETTIMEZONETO'timezone'; ALTERUSERusernameSETTIMEZONETO'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