Mysql – Extremely slow website, MySQLTuner log, any advice


We are running a WordPress site and are having major problems with extremely slow response time for pages that have to miss the Nginx cache.

I'm looking at our database performance as a culprit, and have a MySQLTuner log. What should I be looking at to change/tweak here?

 >>  MySQLTuner 1.7.9 - Major Hayden <>
 >>  Bug reports, feature requests, and downloads at
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 10.1.32-MariaDB-1~jessie
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/lib/mysql/shoegaze.err(0B)
[!!] Log file /var/lib/mysql/shoegaze.err doesn't exist
[!!] Log file /var/lib/mysql/shoegaze.err isn't readable.

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Data in InnoDB tables: 477M (Tables: 229)
[--] Data in MyISAM tables: 564M (Tables: 74)
[OK] Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 2d 17h 4m 19s (8M q [38.070 qps], 143K conn, TX: 170G, RX: 8G)
[--] Reads / Writes: 92% / 8%
[--] Binary logging is enabled (GTID MODE: OFF)
[--] Physical Memory     : 1.0G
[--] Max MySQL memory    : 1.3G
[--] Other process memory: 309.1M
[--] Total buffers: 624.0M global + 7.5M per thread (100 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 895.2M (87.42% of installed RAM)
[!!] Maximum possible memory usage: 1.3G (134.49% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/8M)
[OK] Highest usage of available connections: 36% (36/100)
[OK] Aborted connections: 0.01%  (15/143505)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[OK] Query cache efficiency: 37.9% (4M cached / 11M selects)
[!!] Query cache prunes per day: 20139
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 96K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 31% (131K on disk / 421K total)
[OK] Thread cache hit rate: 99% (36 created / 143K connections)
[OK] Table cache hit rate: 57% (400 open / 691 opened)
[OK] Open file limit used: 1% (219/16K)
[OK] Table locks acquired immediately: 97% (3M immediate / 3M locks)
[OK] Binlog cache memory access: 99.99% (15789 Memory / 15790 Total)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 4 thread(s).
[--] Using default value is good enough for your version (10.1.32-MariaDB-1~jessie)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[OK] Key buffer used: 100.0% (134M used / 134M cache)
[OK] Key buffer size / total MyISAM indexes: 128.0M/226.3M
[OK] Read Key buffer hit rate: 99.8% (53M cached / 134K reads)
[OK] Write Key buffer hit rate: 99.3% (1M cached / 1M writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 256.0M/477.1M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (37.5 %): 48.0M * 2/256.0M should be equal 25%
[!!] InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1).
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 99.99% (29731944 hits/ 29735567 total)
[!!] InnoDB Write Log efficiency: 44.99% (12271 hits/ 27274 total)
[OK] InnoDB log waits: 0.00% (0 waits / 15003 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[!!] Aria pagecache hit rate: 84.8% (860K cached / 131K reads)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.

-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.

-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: STATEMENT
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Performance should be activated for better diagnostics
    Consider installing Sys schema from

Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_size (> 64M)
    tmp_table_size (> 32M)
    max_heap_table_size (> 32M)
    performance_schema = ON enable PFS
    innodb_buffer_pool_size (>= 477M) if possible.
    innodb_log_file_size should be (=32M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
    innodb_buffer_pool_instances (=1)

Best Answer

1GB of RAM is tiny in today's terms. And you have over-allocated it. Are you seeing any swapping? Swapping is terrible for MySQL performance. You seem to have a mixture of MyISAM and InnoDB tables; was that deliberate?

Here are some changes that should help some:

key_buffer_size = 50M
innodb_buffer_pool_size = 300M
aria_pagecache_buffer_size = 32M
query_cache_size -- either 0 or no more than 32M

Note that MyISAM data uses the free space in the OS for caching. The settings you have probably leave virtually no space for such, thereby drastically slowing MyISAM SELECTs.

If you do opt for more RAM, we should revisit the settings after a least a day of uptime -- SHOW GLOBAL STATUS; and SHOW GLOBAL VARIABLES;, plus the new RAM size.

wp_postmeta, as currently specified, is inefficient. Here is advice on improving it.

If nginx's cache is on the same machine, then that is another thing fighting for the limited RAM. "Don't put a cache in front of another cache."