Relational Database ServiceRelational Database Service

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain Service
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Updated at: Apr 02, 2022 GMT+08:00

Suggestions on MySQL Parameter Tuning

Parameters are key configuration items in a database system. Improper parameter settings may adversely affect the stable running of databases. This section describes some important parameters for your reference. For details, visit the MySQL official website.

For details on how to modify MySQL parameters on the console, see Modifying Parameters.

Sensitive Parameters

The following parameters can result in system security and stability issues if set improperly:

  • lower_case_table_names

    Default value: 1

    Function: Controls whether database and tables stored on disks are case sensitive. The value 1 indicates that database and table names are case-insensitive and are lowercase by default.

    MySQL 8.0 does not support this parameter.

    Impact: Changing this parameter value may cause primary/standby replication exceptions. Exercise caution when performing this operation.

    • If you want to change this parameter value from 1 to 0, change it on read replicas and reboot them first, and then repeat the operations on the primary DB instance.
    • If you want to change this parameter value from 0 to 1, change it on the primary DB instance and reboot it first, and then run SELECT @@GLOBAL.GTID_EXECUTED on read replicas. Wait until the result set is at least the same as the primary DB instance and then change this parameter value on read replicas and reboot them.
  • innodb_flush_log_at_trx_commit

    Default value: 1

    Function: Controls the balance between strict ACID compliance for commit operations and higher performance. The default setting of 1 is required for full ACID compliance. Logs are written and flushed to disks at each transaction commit. If the value is set to 0, logs are written and flushed to disks once per second. If the value is set to 2, logs are written at each transaction commit and flushed to disks every two seconds.

    Impact: If this parameter is not set to 1, data security is not guaranteed. If the system fails, data may be lost.

    Recommended value for POC: 2

  • sync_binlog

    Default value: 1

    Function: Controls how often the MySQL server synchronizes binary logs to the disk. The default setting of 1 requires synchronization of the binary log to the disk at each transaction commit. If the value is set to 0, synchronization of the binary log to the disk is not controlled by the MySQL server but relies on the OS to flush the binary log to the disk. This setting provides the best performance, but in the event of a power failure or OS crash, all binary log information in binlog_cache is lost.

    Impact: If this parameter is not set to 1, data security is not guaranteed. If the system fails, data may be lost.

    Recommended value for POC: 1000

  • innodb_large_prefix

    Default value: OFF

    Function: Specifies the maximum length of a single-column index in an InnoDB table.

    This parameter is available only for MySQL 5.6.

    Impact: Changing this parameter value during DDL execution may cause primary/standby replication exceptions. Exercise caution when performing this operation.

    • If you want to change this parameter value from OFF to ON, change it on read replicas first and then on the primary DB instance.
    • If you want to change this parameter value from ON to OFF, change it on the primary DB instance first and then on read replicas.
  • innodb_buffer_pool_size

    Default value: Varies depending on the DB instance classes.

    Function: Specifies the size of the InnoDB buffer pool. The InnoDB buffer pool is used to cache table and index data. Increasing the value of this parameter reduces disk I/O.

    Impact: Setting this parameter to a large value may cause system breakdown. Exercise caution when changing this parameter value.

    Recommended value for POC: 70% to 75% of the memory for your DB instances with 32 GB memory or above

Performance Parameters

The following parameters can affect database performance:

  • The values of innodb_spin_wait_delay and query_alloc_block_size are determined by the DB instance specifications. If you increase their values, database performance may be affected.
  • If key_buffer_size is set to a value smaller than 4096, the parameter modification will fail.
  • If max_connections is set to a small value, database access will be affected.
  • The default values of the following parameters are determined by the DB instance specifications: innodb_buffer_pool_size, max_connections, and back_log. These parameter values are default before being specified.
  • The values of innodb_io_capacity_max and innodb_io_capacity are determined by the storage type. These parameter values are default before being specified.

Associated Parameters

  • character_set_server: If you change the value of this parameter, the system changes the values of collation_server, character_set_database, and collation_database accordingly.

    The parameters character_set_server and collation_server are correlated with each other. For example, for MySQL 5.7, when character_set_server is latin1, the default value of collation_server is latin1_swedish_ci. The collation_server value must start with latin1.

  • innodb_io_capacity: The value of this parameter must be less than or equal to the value of innodb_io_capacity_max. For example, if innodb_io_capacity_max is set to 2000, the maximum value of innodb_io_capacity is 2000.
  • innodb_buffer_pool_size: The value of this parameter must be a multiple of the product of the value for innodb_buffer_pool_chunk_size and innodb_buffer_pool_instances. For example, if innodb_buffer_pool_chunk_size is 134217728 and innodb_buffer_pool_instances is 1, the value of innodb_buffer_pool_size must be a multiple of 134217728.

Other Parameters

  • max_prepared_stmt_count: limits the upper limit of prepared statements. Too many prepared statements consume server memory resources. If this parameter is set to a small value, your DB instance may be vulnerable to the denial of service (DoS) attacks. You are advised to change this parameter value based on service requirements.
  • The values of the following parameters will be adjusted based on kernel rules:
    • key_cache_age_threshold: automatically adjusted to a multiple of 100.
    • join_buffer_size and key_cache_block_size: automatically adjusted to multiples of 128.
    • query_cache_size, query_prealloc_size, innodb_log_buffer_size, max_allowed_packet, and thread_stack: automatically adjusted to multiples of 1024.
    • read_buffer_size, read_rnd_buffer_size, binlog_cache_size, and binlog_stmt_cache_size: automatically adjusted to multiples of 4096.
    • data_buffer_size, log_buffer_size, shared_pool_size, and temp_buffer_size: automatically adjusted to multiples of 1048576.
  • binlog_format: set to row by default, indicating that binary logs are recorded as the modified data by row, including the data before and after modification. You are advised not to change the value of this parameter.
  • log_timestamps: controls the time zone of timestamps in messages written to the error log, and in general query log and slow query log messages written to files. The default value is the system time zone and cannot be changed.
  • skip_name_resolve: set to ON by default, indicating that the system skips domain name resolution and determines whether a connection can be set up based on the IP address in the whitelist.
  • innodb_strict_mode: restricts the InnoDB check policy. The default value is OFF.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel