MySQL my.ini Performance and Optimization Tips

The major advantage of identifying the performance-driving factor for a database is that it allows you to avoid over-provisioning and reduce costs by right-sizing your servers. It also gives you insights into whether moving data storage or adding server capacity will improve performance and, if so, how much it will be.

The tuning database for MySQL query performance optimization doesn’t come with pale challenges. However, once tuned properly, the database gives worthwhile performance results with great functionalities. It lowers unwanted task load and optimizes the MySQL database for faster data retrieval.

I am sharing some of the parameters that have worked for me:

ParameterWorkstationServer
Shared
Database Server
Dedicated
max_connections170800800
query_cache_size8M33M79M
table_cache34015201520
tmp_table_size9M16M28M
thread_cache83838
myisam_sort_buffer_size2M12M28M
key_buffer_size2M5M13M
read_rnd_buffer_size252k256k256k
sort_buffer_size189k256k256k
innodb_additional_mem_pool_size2M4M10M
innodb_log_buffer_size1M2M4M
innodb_buffer_pool_size512M2G3G
innodb_log_file_size10M36M89M
my.ini setting

Other settings:

INNODB specific options

innodb_additional_mem_pool_size=2M

Additional memory pool, which is used by InnoDB to store metadata information. If InnoDB requires more memory it will start to allocate it from the OS. As this is fast enough on most recent operating systems, you normally do not need to change this value. SHOW INNODB STATUS will display the current amount used. Please increase this value slowly to see, if it takes affect for your performance problem.

innodb_flush_log_at_trx_commit=1

If set to 1, InnoDB will flush (fsync) the transaction logs to the disk at each commit, which offers full ACID behavior. If you are willing to compromise this safety, and you are running small transactions, you may set this to 0 or 2 to reduce disk I/O to the logs. Set this value to 0 if you want to restore a database.

innodb_log_buffer_size=10M

The size of the buffer InnoDB uses for buffering log data. As soon as it is full, InnoDB will have to flush it to disk. As it is flushed once per second anyway, it does not make sense to have it very large (even with long transactions). Make sense to increase if you do a database restore.

innodb_buffer_pool_size=92M

InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and row data. The bigger you set this the less disk I/O is needed to access data in tables. On a dedicated database server you may set this parameter up to 80% of the machine physical memory size. Do not set it too large, though, because competition of the physical memory may cause paging in the operating system. Note that on 32bit systems, you might be limited to 2-3.5G of user-level memory per process, so do not set it too high.