All pages
Powered by GitBook
1 of 1

Loading...

Configuring MariaDB for Optimal Performance

Best practices for configuring MariaDB server variables like `innodb_buffer_pool_size`, `aria_pagecache_buffer_size`, and `thread_handling` to maximize resource utilization on dedicated servers.

This article will help you configure MariaDB for optimal performance.

By default, MariaDB is configured to work on a desktop system and therefore use relatively few resources. To optimize installation for a dedicated server, you have to do a few minutes of work.

For this article we assume that you are going to run MariaDB on a dedicated server.

Feel free to update this article if you have more ideas.

my.cnf Files

MariaDB is normally configured by editing the my.cnf file. In the next section you have a list of variables that you may want to configure for dedicated MariaDB servers.

Storage Engine

InnoDB is normally the default storage engine with MariaDB.

  • You should set to about 80% of your memory. The goal is to ensure that 80 % of your working set is in memory.

The other most important InnoDB variables are:

Some other important InnoDB variables:

  • . Deprecated and ignored from .

  • . Deprecated and ignored from .

Storage Engine

  • MariaDB uses by default the Aria storage engine for internal temporary files. If you have many temporary files, you should set to a reasonably large value so that temporary overflow data is not flushed to disk. The default is 128M.

You can check if Aria is configured properly by executing:

If Aria_pagecache_reads is much smaller than Aria_pagecache_read_request andAria_pagecache_writes is much smaller than Aria_pagecache_write_request#, then your setup is good. If the is big enough, the two variables should be 0, like above.

  • If you don't use MyISAM tables explicitly (true for most + users), you can set to a very low value, like 64K.

Using in memory temporary tables

Using memory tables for internal temporary results can speed up execution. However, if the memory table gets full, then the memory table will be moved to disk, which can hurt performance.

You can check how the internal memory tables are performing by executing:

Created_tmp_tables is the total number of internal temporary tables created as part of executing queries like SELECT.Created_tmp_disk_tables shows how many of these did hit the storage.

You can increase the storage for internal temporary tables by setting and high enough. These values are per connection.

Lots of Connections

A Lot of Fast Connections + Small Set of Queries + Disconnects

  • If you are doing a lot of fast connections / disconnects, you should increase and if you are running or below .

  • If you have a lot (> 128) of simultaneous running fast queries, you should consider setting to pool_of_threads.

Connecting From a Lot of Different Machines

  • If you are connecting from a lot of different machines you should increase to the max number of machines (default 128) to cache the resolving of hostnames. If you don't connect from a lot of machines, you can set this to a very low value!

See Also

External Links

This page is licensed: CC BY-SA / Gnu FDL

innodb_thread_concurrency. Deprecated and ignored from .

Performance schema helps you understand what is taking time and resources.
  • Slow query log is used to find queries that are running slow.

  • OPTIMIZE TABLE helps you defragment tables.

  • InnoDB
    innodb_buffer_pool_size
    innodb_log_file_size
    innodb_flush_method
    innodb_thread_sleep_delay
    innodb_max_dirty_pages_pct_lwm
    innodb_read_ahead_threshold
    innodb_buffer_pool_instances
    innodb_adaptive_max_sleep_delay
    Aria
    aria_pagecache_buffer_size
    aria_pagecache_buffer_size
    MyISAM
    key_buffer_size
    max_heap_table_size
    tmp_memory_table_size
    back_log
    thread_cache_size
    thread_handling
    host_cache_size
    MariaDB Memory Allocation
    Full List of MariaDB Options, System and Status Variables
    Server system variables
    mysqld options
    what-to-tune-in-mysql-56-after-installation.html
    optimizing-mysql-configuration-percona-mysql-university-montevideo
    MariaDB [test]> show global status like "Aria%";
    +-----------------------------------+-------+
    | Variable_name                     | Value |
    +-----------------------------------+-------+
    | Aria_pagecache_blocks_not_flushed | 0     |
    | Aria_pagecache_blocks_unused      | 964   |
    | Aria_pagecache_blocks_used        | 232   |
    | Aria_pagecache_read_requests      | 9598  |
    | Aria_pagecache_reads              | 0     |
    | Aria_pagecache_write_requests     | 222   |
    | Aria_pagecache_writes             | 0     |
    | Aria_transaction_log_syncs        | 0     |
    +-----------------------------------+-------+
    MariaDB [test]> show global status like "Created%tables%";
    +-------------------------+-------+
    | Variable_name           | Value |
    +-------------------------+-------+
    | Created_tmp_disk_tables | 1     |
    | Created_tmp_tables      | 2     |
    +-------------------------+-------+
    MariaDB 10.5.1
    MariaDB 10.5.5
    MariaDB 10.4
    MariaDB 10.1
    MariaDB 10.5.5