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 MySQL 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. For example, to enable
slow query logging,
you must set both the slow_query_log flag to on and the log_output flag
to FILE to make your logs available using the Google Cloud Console Logs Viewer.
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.
Configuring database flags
Setting a database flag
Console
- In the Google Cloud Console, create a new Cloud Console project, or open an existing project by selecting the project name.
- Open the instance and click Edit.
- Scroll down 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 do not take a value, specify the flag name followed by an equals sign ("=").
For example, to set the general_log,
skip_show_database, and wait_timeout flags, you
can use the following command:
gcloud sql instances patch [INSTANCE_NAME] --database-flags \
general_log=on,skip_show_database=on,wait_timeout=200000
REST API v1beta4
To set a flag for an existing database:
Before using any of the request data below, 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:
For example, to set the general_log flag for an existing
database use:
Before using any of the request data below, 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": "general_log",
"value": "on"
}
]
}
}
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.
Clearing all flags to their default value
Console
- In the Google Cloud Console, create a new Cloud Console project, or open an existing project by selecting the project name.
- 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 API v1beta4
To clear all flags for an existing instance:
Before using any of the request data below, 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:
Viewing current values of database flags
To view all current values of the MySQL system variables, log into your instance with themysql client and enter the following statement:
SHOW VARIABLES;
Note that you can change the value only for supported flags (as listed below).
Determining what database flags have been set for an instance
To see what flags have been set for a Cloud SQL instance:
Console
- In the Google Cloud Console, create a new Cloud Console project, or open an existing project by selecting the project name.
- 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 API v1beta4
To list flags configured for an instance:
Before using any of the request data below, 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
The flags supported in Cloud SQL are the most commonly requested flags for MySQL. Flags not mentioned below are not supported.
For a given flag, Cloud SQL might support a different range from the corresponding MySQL parameter or option.
The flags apply to all versions of MySQL supported by Cloud SQL except where noted.
A | B | C | D | E | F | G | I | L | M | N | O | P | Q | R | S | T | U | W
| Cloud SQL Flag | Type Acceptable Values and Notes |
Restart Required? |
|---|---|---|
| activate_all_roles_on_login |
boolean on | off
default: off
|
No |
| auto_increment_increment | integer 1 ... 65535 |
No |
| auto_increment_offset | integer1 ... 65535 |
No |
| binlog_cache_size | integer4096 ... 9223372036854775807 |
No |
| binlog_expire_log_seconds | integer0 ... 4294967295 MySQL 8.0 only. Default is 2592000, which equals 30 days. See the Tips section for more information about this flag. |
No |
| binlog_group_commit_sync_delay | 0 ... 1000000
Default is 0. |
No |
| binlog_group_commit_sync_no_delay_count | 0 ... 1000000
Default is 0. |
No |
| binlog_row_image | enumerationfull (default), minimal, or noblob |
No |
| binlog_stmt_cache_size | 4096 ... 9223372036854775807 |
No |
| binlog_transaction_dependency_history_size | integer
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| binlog_transaction_dependency_tracking | enumeration
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| character_set_server | stringutf8 or utf8mb4 (recommended) |
Yes |
| default_password_lifetime | integer 0...65535
default: 0
|
No |
| default_time_zone | stringSpecify values as time zone offsets, from -12:59 to +13:00. Leading zeros required.
For example, London is in the UTC time zone, which is +00:00 in the supported values for this flag. Named areas, such as 'Europe/London', are not supported by Cloud SQL. |
Yes |
| disconnect_on_expired_password | boolean on | off
default: on
|
Yes |
| eq_range_index_dive_limit | integer0 ... 2147483647 |
No |
| event_scheduler | booleanon | off
If you are using the Event Scheduler, configure your instance with an activation policy of ALWAYS to ensure that scheduled events run. |
No |
| expire_log_days | integer0 ... 99 Default is 0, which means no automatic removal. See the Tips section for more information about this flag. |
No |
| explicit_defaults_for_timestamp | booleanon | off |
No |
| ft_max_word_len | integer10 ... 252 |
Yes |
| ft_min_word_len | integer1 ... 16 |
Yes |
| ft_query_expansion_limit | integer0 ... 1000 |
Yes |
| general_log | booleanon | off
See the Tips section for more information about general logs. |
No |
| generated_random_password_length | integer 5-255
default: 20
|
No |
| group_concat_max_len | integer4 ... 17179869184 |
No |
| init_connect | string |
No |
| innodb_adaptive_hash_index | booleanon | off |
No |
| innodb_adaptive_hash_index_parts | integer1 ... 512 |
Yes |
| innodb_adaptive_max_sleep_delay | integer0 ... 1000000 |
No |
| innodb_autoinc_lock_mode | integer0 ... 2 |
Yes |
| innodb_buffer_pool_size | integer
Setting this flag for MySQL 5.6 requires a restart. See the Tips section for more information about this flag. | No |
| innodb_change_buffer_max_size | integer0 ... 50 |
No |
| innodb_concurrency_tickets | integer1 ... 4294967295 |
No |
| innodb_file_per_table | booleanon | off
See the Tips section for more information about this flag. |
No |
| innodb_fill_factor | integer10 ... 100 |
No |
| innodb_ft_cache_size | integer1600000 ... 80000000 |
Yes |
| innodb_ft_enable_diag_print | booleanon | off |
No |
| innodb_ft_enable_stopword | booleanon | off |
No |
| innodb_ft_max_token_size | integer10 ... 252
Supported only in MySQL 5.6 and later versions. |
Yes |
| innodb_ft_min_token_size | integer0 ... 16
Supported only in MySQL 5.6 and later versions. |
Yes |
| innodb_ft_num_word_optimize | integer1000 ... 10000 |
No |
| innodb_ft_result_cache_limit | integer1000000 ... 4294967295 |
No |
| innodb_ft_server_stopword_table | string
Supported only in MySQL 5.6 and later versions. |
No |
| innodb_ft_sort_pll_degree | integer1 ... 32 |
Yes |
| innodb_ft_total_cache_size | integer32000000 ... 1600000000 |
Yes |
| innodb_ft_user_stopword_table | string |
No |
| innodb_large_prefix | booleanon | off
Supported only in MySQL 5.6. |
No |
| innodb_lock_wait_timeout | integer1 ... 1073741824 |
No |
| innodb_log_buffer_size | integer262144 ... 4294967295 |
Yes |
| innodb_log_file_size | integerMySQL 5.6: 1048576 ... 274877906944MySQL 5.7: 4194304 ... 274877906944
|
Yes |
| innodb_lru_scan_depth | integer100 ... 9223372036854775807 |
No |
| innodb_old_blocks_pct | integer5 ... 95 |
No |
| innodb_old_blocks_time | integer0 ... 4294967295 |
No |
| innodb_online_alter_log_max_size | integer65536 ... 9223372036854775807 |
No |
| innodb_optimize_fulltext_only | booleanon | off |
No |
| innodb_print_all_deadlocks | booleanon | off |
No |
| innodb_purge_threads | 1 ... 32
Supported in MySQL 5.6, 5.7, 8.0 Default is 1. |
Yes |
| innodb_random_read_ahead | booleanon | off |
No |
| innodb_read_ahead_threshold | integer0 ... 64 |
No |
| innodb_read_io_threads | integer1 ... 64
|
Yes |
| innodb_replication_delay | integer0 ... 4294967295 |
No |
| innodb_rollback_on_timeout | booleanon | off |
Yes |
| innodb_rollback_segments | integer1 ... 128 |
No |
| innodb_sort_buffer_size | integer65536 ... 67108864 |
Yes |
| innodb_stats_auto_recalc | booleanon | off |
No |
| innodb_stats_method | enumerationnulls_equal | nulls_unequal | nulls_ignored |
No |
| innodb_stats_on_metadata | booleanon | off |
No |
| innodb_stats_persistent | booleanon | off |
No |
| innodb_stats_persistent_sample_pages | integer1 ... 9223372036854775807 |
No |
| innodb_stats_sample_pages | integer1 ... 9223372036854775807 |
No |
| innodb_stats_transient_sample_pages | integer1 ... 9223372036854775807 |
No |
| innodb_status_output | booleanon | off |
No |
| innodb_status_output_locks | booleanon | off |
No |
| innodb_strict_mode | booleanon | off |
No |
| innodb_sync_array_size | 1 ... 1024
Supported in MySQL 5.6, 5.7, 8.0 Default is 1. |
Yes |
| innodb_thread_concurrency | integer0 ... 1000 |
No |
| innodb_thread_sleep_delay | integer0 ... 1000000 |
No |
| innodb_write_io_threads | integer1 ... 64 |
Yes |
| interactive_timeout | integer1 ... 31536000 |
No |
| join_buffer_size | integer128 ... 9223372036854775807 |
No |
| local_infile | booleanon | off |
No |
| lock_wait_timeout | integer1 ... 31536000 |
No |
| log_bin_trust_function_creators | booleanon | off |
No |
| log_output | setFILE | TABLE | NONE |
No |
| log_queries_not_using_indexes | booleanon | off |
No |
| log_throttle_queries_not_using_indexes | integer0 ... 9223372036854775807 |
No |
| long_query_time | float0 ... 30000000
Cloud SQL provides the ability to set this flag to less than 1 if needed. If the |
No |
| lower_case_table_names | integer0 or 1
In most cases, use the default value of 0, which makes table and database names case sensitive. If you need to change the value of this flag, make sure that you understand how the change will affect your existing tables and databases. |
Yes |
| mandatory_roles | string role name
default: empty string
|
No |
| max_allowed_packet | integer16384 ... 1073741824
This value must be a multiple of 1024, if sql_mode=TRADITIONAL or sql_mode=STRICT_ALL_TABLES. |
No |
| max_binlog_size | integer4096 ... 1073741824 |
No |
| max_connections | integer14 ... 262143
|
Yes |
| max_digest_length | integer0 ... 1048576 |
Yes |
| max_execution_time | integer0 ... 9223372036854775807 |
No |
| max_heap_table_size | integer16384 ... 67108864
See the Tips section for more information about this flag. |
No |
| max_join_size | integer16 ... 9223372036854775807 |
No |
| max_length_for_sort_data | integer4 ... 8388608 |
No |
| max_points_in_geometry | integer3 ... 1048576 |
No |
| max_prepared_stmt_count | integer0 ... 1048576 |
No |
| max_seeks_for_key | integer1 ... 9223372036854775807 |
No |
| max_sort_length | integer4 ... 8388608 |
No |
| max_sp_recursion_depth | integer0 ... 255 |
No |
| max_user_connections | integer0 ... 4294967295 |
No |
| max_write_lock_count | integer1 ... 9223372036854775807 |
No |
| net_read_timeout | integer30 ... 4294967295 |
No |
| net_retry_count | integer10 ... 4294967295 |
No |
| net_write_timeout | integer60 ... 4294967295 |
No |
| optimizer_prune_level | integer0 ... 1 |
No |
| optimizer_search_depth | integer0 ... 62 |
No |
| optimizer_trace_max_mem_size | integer0 ... 9223372036854775807 |
No |
| optimizer_trace_offset | integer-9223372036854775808 ... 9223372036854775807 |
No |
| parser_max_mem_size | integer10000000 ... 9223372036854775807 |
No |
| password_history | integer 0-4294967295
default: 0
|
No |
| password_require_current | boolean on | off
default: off
|
No |
| password_reuse_interval | integer 0-4294967295
default: 0
|
No |
| performance_schema | booleanon | off (default)
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_accounts_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_digests_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_stages_history_long_size | integer-1 ... 1048576 |
Yes |
| performance_schema_events_stages_history_size | integer-1 ... 1024
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_statements_history_long_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_statements_history_size | integer-1 ... 1024
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_transactions_history_long_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_transactions_history_size | integer-1 ... 1024
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_waits_history_long_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_events_waits_history_size | integer-1 ... 1024
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_hosts_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_cond_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_cond_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_digest_length | integer0 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_file_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_file_handles | integer0 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_file_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_index_stat | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_memory_classes | integer0 ... 1024
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_metadata_locks | integer-1 ... 104857600
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_mutex_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_mutex_instances | integer-1 ... 104857600
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_prepared_statements_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_program_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_rwlock_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_rwlock_instances | integer-1 ... 104857600
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_socket_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_socket_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_sql_text_length | integer0 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_stage_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_statement_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_statement_stack | integer1 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_table_handles | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_table_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_table_lock_stat | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_thread_classes | integer0 ... 256
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_max_thread_instances | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_session_connect_attrs_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_setup_actors_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_setup_objects_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| performance_schema_users_size | integer-1 ... 1048576
See Tips section for more information about performance_schema flags. |
Yes |
| query_alloc_block_size | integer1024 ... 4294967295 |
No |
| query_cache_limit | integer0 ... 223338299392This flag is not available for MySQL 8.0 as the query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. |
No |
| query_cache_min_res_unit | integer0 ... 9223372036854775807This flag is not available for MySQL 8.0 as the query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. |
No |
| query_cache_size | integer0 ... 223338299392This flag is not available for MySQL 8.0 as the query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. See the Tips section for more information about this flag. |
No |
| query_cache_type | enumeration0 ... 2This flag is not available for MySQL 8.0 as the query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. See the Tips section for more information about this flag. |
Yes |
| query_cache_wlock_invalidate | booleanon | offThis flag is not available for MySQL 8.0 as the query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. |
No |
| query_prealloc_size | integer8192 ... 9223372036854775807 |
No |
| range_alloc_block_size | integer4096 ... 4294967295 |
No |
| range_optimizer_max_mem_size | integer0 ... 9223372036854775807 |
No |
| read_buffer_size | integer8192 ... 2147483647 |
No |
| read_only | booleanon | off
Has no effect for replicas. |
No |
| read_rnd_buffer_size | integer1 ... 2147483647 |
No |
| show_compatibility_56 | booleanon | off
Supported only in MySQL 5.7. |
No |
| skip_show_database | flagon | off |
Yes |
| slave_parallel_type | enumeration
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| slave_parallel_workers | integer
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| slave_preserve_commit_order | boolean
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| slave_pending_jobs_size_max | integer
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| slow_query_log | booleanon | offSee the Tips section for more information on slow query logs. |
No |
| sort_buffer_size | integer32768 ... 9223372036854775807 |
No |
| sql_mode | string
See the Server SQL Modes in the MySQL documentation for allowed values, including combined modes such as |
No |
| stored_program_cache | integer16 ... 524288 |
No |
| sync_binlog | integer0 ... 4294967295
Supported only on read replicas and external server replicas in MySQL 5.7 and 8.0. The default setting of 1 enables the synchronization of the binary log to disk before transactions are committed. This flag is not supported on primary instances or legacy HA failover replicas. If a replica using this flag is promoted, the flag is removed. |
No |
| table_definition_cache | integer400 ... 524288 |
No |
| table_open_cache | integer1 ... 524288 |
No |
| table_open_cache_instances | integer1 ... 64 |
Yes |
| thread_cache_size | integer0 ... 16384 |
No |
| thread_stack | integer131072 ... 9223372036854775807 |
Yes |
| tmp_table_size | integer1024 ... 67108864
See the Tips section for more information about this flag. |
No |
| transaction_alloc_block_size | integer1024 ... 131072 |
No |
| transaction_isolation | enumerationREAD-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE |
Yes |
| transaction_prealloc_size | integer1024 ... 131072 |
No |
| transaction_write_set_extraction | enumeration
For information about how to use this flag and its acceptable values, see Configuring parallel replication. |
No |
| updatable_views_with_limit | integer0 ... 1 |
No |
| wait_timeout | integer1 ... 31536000 |
No |
Tips for working with flags
- general_log, slow_query_log
-
To make your
generalorslow querylogs available, enable the corresponding flag and set thelog_outputflag toFILE. This makes the log output available using the Logs Viewer in the Google Cloud Console. Note that Google Cloud's operations suite logging charges apply. To minimize instance storage cost,generalandslow querylogs on the instance disk will be rotated when the log file is older than 24 hours (and no changes have been made within that duration) or greater than 100MB in size. Old log files will be automatically deleted after the rotation.If
log_outputis set toNONE, you will be unable to access the logs. If you setlog_outputtoTABLE, the log output is placed in a table in your database. If this table becomes large, it can affect instance restart time or cause the instance to lose its SLA coverage; for this reason, theTABLEoption is not recommended. If needed, you can truncate your log tables by using the API. For more information, see the instances.truncateLog reference page.
- expire_logs_days, binlog_expire_logs_seconds
- If you enable point-in-time recovery, the expiration period of your binary logs will be determined by the lesser of your transaction log retention period and the value of this flag. For more information, see the transaction log retention page.
- innodb_buffer_pool_size
The value of the innodb_buffer_pool_size is the size in bytes of the buffer pool. You cannot enable this flag on instances that have fewer than 3,840 MiB of RAM.
This flag is not configurable for shared-core machine types (f1_micro and g1_small). Changing this flag on MySQL 5.6 requires a restart.
In Cloud SQL, the default, minimum allowable, and maximum allowable values of the innodb_buffer_pool_size flag depend on the instance's memory. These values can be roughly calculated as a percentage of the instance's RAM. By default, the value of this flag is typically set close to the maximum allowable value. The maximum allowable allocation percentage increases with instance size. The minimum allowable value is usually about 20% of the instance's RAM.
Approximate values for this flag:
Instance RAM Range Min % Default % Max % 0 - 4.0GB of RAM ~34% 4.0GB - 7.5GB ~20% ~34% ~34% 7.5GB - 12GB ~20% ~52% ~52% 12GB - 24GB ~20% ~67% ~67% 24GB and above ~20% ~72% ~72% Your exact values may vary. To calculate the current value for your instance, you can run the query:
show global variables like 'innodb_buffer_pool_size'
For reference, the minimum allowable, default, and maximum allowable values are provided for the predefined machine types below.
Predefined machine type Instance RAM (GB) Min (GB)
(% of total)Default (GB)
(% of total)Max (GB)
(% of total)f1-micro 0.6 - 0.053 - g1-small 1.7 - 0.625 - db-custom-1-3840 3.75 0.875
(23%)1.375
(37%)1.375
(37%)db-custom-2-7680 7.5 1.5
(20%)4
(53%)4
(53%)db-custom-4-15360 15 3
(20%)10.5
(70%)10.5
(70%)db-custom-8-30720 30 6
(20%)22
(73%)22
(73%)db-custom-16-61440 60 12
(20%)44
(73%)44
(73%)db-custom-32-122880 120 24
(20%)87
(73%)87
(73%)db-custom-64-245760 240 48
(20%)173
(72%)173
(72%)db-custom-96-368640 360 72
(20%)260
(72%)260
(72%)db-custom-2-13312 13 3
(23%)9
(69%)9
(69%)db-custom-4-26624 26 6
(23%)19
(73%)19
(73%)db-custom-8-53248 52 11
(21%)38
(73%)38
(73%)db-custom-16-106496 104 21
(20%)75
(72%)75
(72%)db-custom-32-212992 208 42
(20%)150
(72%)150
(72%)db-custom-64-425984 416 84
(20%)300
(72%)300
(72%)db-custom-96-638976 624 125
(20%)450
(72%)450
(72%)
For all MySQL versions 5.6 and higher, the default value is ON.
Exhausting the available instance memory can occur when you set
tmp_table_size and max_heap_table_size too high for
the number of concurrent queries the instance processes. Exhausting the memory
will result in an instance crash and restart.
For more information about working with these flags, see How MySQL Uses Internal Temporary Tables and The MEMORY Storage Engine.
You cannot enable this flag on instances that have fewer than 26,624 MiB of RAM. If you enable this flag, you cannot change your machine type to a size that does not support the flag; you must first disable this flag.
Flags managed by Cloud SQL
Cloud SQL adjusts certain system flags depending on the instance machine type. You cannot adjust these values.
- innodb_buffer_pool_instances
-
- 1 for db-f1-micro and db-g1-small.
- 1 if RAM < 7.5 GB.
- 2 if 7.5 GB <= RAM < 13 GB.
- 4 if 13 GB <= RAM < 26 GB.
- 8 if RAM >= 26 GB.
Troubleshooting
Click the links in the table for details:
| For this problem... | The issue might be... | Try this... |
|---|---|---|
| Enabling a flag crashes the instance. | The max_connections flag value may be set too high. |
Contact customer support to request a flag removal. |
| Time zone doesn't automatically change. | Automated time zone change is not supported. | Time must be changed manually. Learn more. |
Bad syntax for dict arg. |
Complex parameter values require special treatment. | Learn more. |
Enabling a flag crashes the instance
After enabling a flag the instances loop between panicking and crashing.
The issue might be
Setting the max_connections flag value too high causes this error.
Things to try
Contact customer support to request a
flag removal followed by a hard drain. This forces the instance to
restart on a different host with a fresh configuration without the undesired
flag or setting.
Time zone doesn't automatically change
The time zone didn't automatically change for daylight savings time.
The issue might be
Automated time zone changes are not supported in Cloud SQL and must be done manually, and not by string but by time zone offset value.
Things to try
Edit the instance to change the default_time_zone flag. Named
areas are not supported. For example:
Europe/LondonLondon is in the UTC time zone, which would
be a supported value of +00:00 for the
default_time_zone flag.
Bad syntax for dict arg
You see the error message Bad syntax for dict arg when trying
to set a flag.
The issue might be
Complex parameter values, such as comma-separated lists, require special treatment when used with gcloud commands.
Things to try
Use the gcloud --flags-file parameter, which specifies a YAML or JSON file containing a --flag:value dictionary useful for complex flag values.
What's next
- Learn more about MySQL system variables.
- Learn more about Operational Guidelines.