I ran MySQLTuner and wondered if anyone would go over the results with me, specifically query cache and temporary tables

dba.stackexchange https://dba.stackexchange.com/questions/203426

Question

Here are the results of MySQLTuner:

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials from debian maintenance account.
[OK] Currently running supported MySQL version 5.7.21-0ubuntu0.16.04.1
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysql/error.log(15K)
[OK] Log file /var/log/mysql/error.log exists
[OK] Log file /var/log/mysql/error.log is readable.
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[!!] /var/log/mysql/error.log contains 11 warning(s).
[OK] /var/log/mysql/error.log doesn't contain any error.
[--] 0 start(s) detected in /var/log/mysql/error.log
[--] 0 shutdown(s) detected in /var/log/mysql/error.log

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in InnoDB tables: 3M (Tables: 54)
[OK] Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'admin_default@%' hasn't specific host restriction.
[!!] User 'admin_rpgc@%' hasn't specific host restriction.
[!!] There is no basic password file list!

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

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 34d 13h 45m 15s (485K q [0.163 qps], 165K conn, TX: 520M, RX: 83M)
[--] Reads / Writes: 94% / 6%
[--] Binary logging is disabled
[--] Physical Memory     : 2.0G
[--] Max MySQL memory    : 299.5M
[--] Other process memory: 157.2M
[--] Total buffers: 177.0M global + 1.8M per thread (70 max threads)
[--] P_S Max memory usage: 72B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 192.8M (9.41% of installed RAM)
[OK] Maximum possible memory usage: 299.5M (14.62% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/485K)
[OK] Highest usage of available connections: 12% (9/70)
[!!] Aborted connections: 51.53%  (85302/165532)
[!!] 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.
[!!] Query cache efficiency: 0.0% (0 cached / 157K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (196 temp sorts / 44K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 46% (27K on disk / 59K total)
[OK] Thread cache hit rate: 99% (9 created / 165K connections)
[!!] Table cache hit rate: 0% (64 open / 269K opened)
[OK] Open file limit used: 0% (4/1K)
[OK] Table locks acquired immediately: 100% (10K immediate / 10K locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 72B
[--] Sys schema is installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (3M used / 16M cache)
[OK] Key buffer size / total MyISAM indexes: 16.0M/43.0K
[!!] Read Key buffer hit rate: 62.9% (272 cached / 101 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 128.0M/3.6M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (4276367247 hits/ 4276367871 total)
[!!] InnoDB Write Log efficiency: 278.6% (19527 hits/ 7009 total)
[OK] InnoDB log waits: 0.00% (0 waits / 26536 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.

-------- 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: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysql/error.log file
    Restrict Host for user@% to user@SpecificDNSorIp
    Reduce or eliminate unclosed connections and network issues
    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
    Increase table_open_cache gradually to avoid file descriptor limits
    Read this before increasing table_open_cache over 64: http://bit . ly/1mi7c4C
    This is MyISAM only table_cache scalability problem, InnoDB not affected.
    See more details here: https://bugs.mysql.com/bug.php?id=49177
    This bug already fixed in MySQL 5.7.9 and newer MySQL versions.
    Beware that open_files_limit (1024) variable
    should be greater than table_open_cache (64)
    Read this before changing innodb_log_file_size and/or innodb_log_files_in_group: http://bit . ly/2wgkDvS
Variables to adjust:
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    table_open_cache (> 64)
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

Should I enable query_cache?

And is there a way to reduce the creation of so many temporary tables?

Under the variables to adjust section, do those sound like good choices? I have a server with 2GB RAM and don't use all of it, would increasing max usage help at all?

EDIT:

my.cnf

mysql/error.log

SHOW GLOBAL STATUS;

SHOW GLOBAL VARIABLES;

SHOW ENGINE INNODB STATUS;

top

ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 289215
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 289215
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs       60G  3.8G   57G   7% /
devtmpfs        1.0G     0  1.0G   0% /dev
tmpfs           1.0G     0  1.0G   0% /dev/shm
tmpfs           1.0G  104M  921M  11% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.0G     0  1.0G   0% /sys/fs/cgroup
none            1.0G     0  1.0G   0% /run/shm

free -m

              total        used        free      shared  buff/cache   available
Mem:           2048        1109         187         263         750         827
Swap:          2048         246        1801
Was it helpful?

Solution

No, do not enable Query Cache. V 8.0 announcements include QC will NOT be available and will be REMOVED. Besides, QC only encourages low quality development.

Suggestions for your my.cnf-ini [mysqld] section

tmp_table_size=40M  # from 16M to reduce TT creations
max_heap_table_size=40M  # from 16M - should ALWAYS be same size as tmp_table_size
max_connections=36  # from 70 because in 30+ days, you had 9 max_used_connections
key_buffer_size=8M  # from 16M - because only 3M used
log_warnings=2  # for addl error.log info on connection errors

OTHER TIPS

Additional Suggestions to be considered.

ulimit -n 5000
in Ubunto to enable more file handle capacity from 1K current OS limit.

In your my.cnf-ini [mysqld] section, more Suggestions on 4/13/2018 early AM

max_connect_errors=10  # why allow hacker/cracker 100 opportunities to guess PW?
thread_cache_size=32  # from 8 to improve thread concurrency
lock_wait_timeout=300  # from 1year (3153600 seconds) for reasonable timeout
expire_logs_days=30  # from 0 for limited historical logs
innodb_print_all_deadlocks=ON  # from OFF - you will WANT the information for corrective action
innodb_read_ahead_threshold=8  # from 56 to read next EXTENT earlier
innodb_stats_sample_pages=32  # from 8 for more accurate NDX cardinality
max_join_size=1000000000  # from a HUGE number for 1Billion row limit
max_seeks_for_key=32  # from a HUGE number, after nn NDX tries, scan table
max_write_lock_count=32  # from a HUGE number, give RD a chance after nn locks
table_open_cache=1024  # from 64 to reduce table_open_cache_misses
open_files_limit=3K  # from 1024 to support volume of tables, definitions, files used
query_cache_size=0  # from 1M - QC not being used today
query_cache_limit=1K  # to conserve RAM for other purposes, QC not used
query_cache_min_res_unit=512  # for more RESULTS in QC, if ever used
slow_query_log=ON  # from OFF  to be aware of ATTENTION needed to improve

My next day in office will be May 2, 2018. Good luck

You have a tiny dataset on a tiny server (or VM). The SlowLog will indicate that some queries are poorly written; fix them. You "can't tune your way out of a performance problem".

Do not turn on the QC.

(I might have more to say, but the VARIABLES and GLOBAL STATUS have expired on pastebin.)

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top