Analysis of GLOBAL STATUS and VARIABLES:
Observations:
- Version: 10.4.12-MariaDB
- 32 GB of RAM
- Uptime = 19d 23:11:43
- It appears that you are running both MyISAM and InnoDB.
- 240 QPS
The More Important Issues:
Change long_query_time
to 1
so you can catch more queries in the slowlog. (You have 10 seconds now; this probably explains why you found only 4 queries.)
There are several clues that some of the queries are running inefficiently. Here's a way to find such queries: http://mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog
Why are you using MyISAM? The values are confusing -- it is as if you [re]built an index for a large MyISAM table, but did not do much else. In most cases, it is better to use InnoDB.
innodb_buffer_pool_size
can probably be increased to improve InnoDB query speed.
Be cautious about the general_log
-- it fills up the disk rather rapidly.
The "Query Cache" is running inefficiently. I recommend turning it completely off: query_cache_type=off
and query_cache_size=0
.
Max_used_connections
hit 152, indicating that a lot of users are connected at the same time. (This does not say that 152 queries were running simultaneously.)
Details and other observations:
Conversion from MyISAM to InnoDB
( Key_blocks_used * 1024 / key_buffer_size ) = 460 * 1024 / 128M = 0.35%
-- Percent of key_buffer used. High-water-mark.
-- Lower key_buffer_size (now 134217728) to avoid unnecessary memory usage.
( (key_buffer_size / 0.20 + innodb_buffer_pool_size / 0.70) ) = ((128M / 0.20 + 8192M / 0.70)) / 32768M = 37.7%
-- Most of available ram should be made available for caching.
-- http://mysql.rjweb.org/doc.php/memory
( general_log ) = general_log = ON
-- Log (FILE or TABLE) of all queries run.
-- Turn off the general_log (now ON) when not in use. That log can fill up the disk very rapidly.
( innodb_buffer_pool_size ) = 8,192 / 32768M = 25.0%
-- % of RAM used for InnoDB buffer_pool
-- Set to about 70% of available RAM. (To low is less efficient; too high risks swapping.)
( (key_buffer_size / 0.20 + innodb_buffer_pool_size / 0.70) ) = ((128M / 0.20 + 8192M / 0.70)) / 32768M = 37.7%
-- (metric for judging RAM usage)
( innodb_lru_scan_depth * innodb_page_cleaners ) = 1,024 * 4 = 4,096
-- Amount of work for page cleaners every second.
-- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixable by lowering lru_scan_depth: Consider 1000 / innodb_page_cleaners (now 4). Also check for swapping.
( innodb_lru_scan_depth ) = 1,024
-- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixed by lowering lru_scan_depth
( innodb_io_capacity ) = 200
-- When flushing, use this many IOPs.
-- Reads could be slugghish or spiky.
( Innodb_log_writes ) = 43,856,157 / 1725103 = 25 /sec
( Innodb_os_log_written / (Uptime / 3600) / innodb_log_files_in_group / innodb_log_file_size ) = 137,804,939,264 / (1725103 / 3600) / 2 / 48M = 2.86
-- Ratio
-- (see minutes)
( Uptime / 60 * innodb_log_file_size / Innodb_os_log_written ) = 1,725,103 / 60 * 48M / 137804939264 = 10.5
-- Minutes between InnoDB log rotations Beginning with 5.6.8, this can be changed dynamically; be sure to also change my.cnf.
-- (The recommendation of 60 minutes between rotations is somewhat arbitrary.) Adjust innodb_log_file_size (now 50331648). (Cannot change in AWS.)
( innodb_flush_method ) = innodb_flush_method = fsync
-- How InnoDB should ask the OS to write blocks. Suggest O_DIRECT or O_ALL_DIRECT (Percona) to avoid double buffering. (At least for Unix.) See chrischandler for caveats about O_ALL_DIRECT
( default_tmp_storage_engine ) = default_tmp_storage_engine =
( innodb_flush_neighbors ) = 1
-- A minor optimization when writing blocks to disk.
-- Use 0 for SSD drives; 1 for HDD.
( innodb_io_capacity ) = 200
-- I/O ops per second capable on disk . 100 for slow drives; 200 for spinning drives; 1000-2000 for SSDs; multiply by RAID factor.
( innodb_adaptive_hash_index ) = innodb_adaptive_hash_index = ON
-- Usually should be ON.
-- There are cases where OFF is better. See also innodb_adaptive_hash_index_parts (now 8) (after 5.7.9) and innodb_adaptive_hash_index_partitions (MariaDB and Percona). ON has been implicated in rare crashes (bug 73890). 10.5.0 decided to default OFF.
( innodb_print_all_deadlocks ) = innodb_print_all_deadlocks = OFF
-- Whether to log all Deadlocks.
-- If you are plagued with Deadlocks, turn this on. Caution: If you have lots of deadlocks, this may write a lot to disk.
( character_set_server ) = character_set_server = latin1
-- Charset problems may be helped by setting character_set_server (now latin1) to utf8mb4. That is the future default.
( local_infile ) = local_infile = ON
-- local_infile (now ON) = ON is a potential security issue
( Key_blocks_used * 1024 / key_buffer_size ) = 460 * 1024 / 128M = 0.35%
-- Percent of key_buffer used . High-water-mark.
-- Lower key_buffer_size (now 134217728) to avoid unnecessary memory usage.
( Key_writes / Key_write_requests ) = 19,978,377 / 40284646 = 49.6%
-- key_buffer effectiveness for writes
-- If you have enough RAM, it would be worthwhile to increase key_buffer_size (now 134217728).
( query_cache_size ) = 524,288 = 0.5MB
-- Size of QC
-- Too small = not of much use. Too large = too much overhead. Recommend either 0 or no more than 50M.
( Qcache_lowmem_prunes ) = 125,234,412 / 1725103 = 73 /sec
-- Running out of room in QC
-- increase query_cache_size (now 524288)
( Qcache_lowmem_prunes/Qcache_inserts ) = 125,234,412/146211296 = 85.7%
-- Removal Ratio (frequency of needing to prune due to not enough memory)
( Qcache_not_cached ) = 78,413,835 / 1725103 = 45 /sec
-- SQL_CACHE attempted, but ignored
-- Rethink caching; tune qcache
( Qcache_hits / Qcache_inserts ) = 37,201,050 / 146211296 = 0.254
-- Hit to insert ratio -- high is good
-- Consider turning off the query cache.
( Qcache_hits / (Qcache_hits + Com_select) ) = 37,201,050 / (37201050 + 282029692) = 11.7%
-- Hit ratio -- SELECTs that used QC
-- Consider turning off the query cache.
( Qcache_hits / (Qcache_hits + Qcache_inserts + Qcache_not_cached) ) = 37,201,050 / (37201050 + 146211296 + 78413835) = 14.2%
-- Query cache hit rate
-- Probably best to turn off the QC.
( (query_cache_size - Qcache_free_memory) / Qcache_queries_in_cache / query_alloc_block_size ) = (524288 - 78344) / 82 / 16384 = 0.332
-- query_alloc_block_size vs formula
-- Adjust query_alloc_block_size (now 16384)
( Created_tmp_tables ) = 96,501,765 / 1725103 = 56 /sec
-- Frequency of creating "temp" tables as part of complex SELECTs.
( Created_tmp_disk_tables ) = 23,539,653 / 1725103 = 14 /sec
-- Frequency of creating disk "temp" tables as part of complex SELECTs
-- increase tmp_table_size (now 16777216) and max_heap_table_size (now 16777216).
Check the rules for temp tables on when MEMORY is used instead of MyISAM. Perhaps minor schema or query changes can avoid MyISAM.
Better indexes and reformulation of queries are more likely to help.
( Created_tmp_disk_tables / Questions ) = 23,539,653 / 414140316 = 5.7%
-- Pct of queries that needed on-disk tmp table.
-- Better indexes / No blobs / etc.
( Select_full_join / Com_select ) = 30,333,225 / 282029692 = 10.8%
-- % of selects that are indexless joins
-- Add suitable index(es) to tables used in JOINs.
( Com_insert + Com_delete + Com_delete_multi + Com_replace + Com_update + Com_update_multi ) = (87669877 + 27242 + 0 + 0 + 1452911 + 0) / 1725103 = 52 /sec
-- writes/sec
-- 50 writes/sec + log flushes will probably max out I/O write capacity of HDD drives. If you have SSD, then this metric is probably fine.
( binlog_format ) = binlog_format = MIXED
-- STATEMENT/ROW/MIXED.
-- ROW is preferred by 5.7 (10.3)
( long_query_time ) = 10
-- Cutoff (Seconds) for defining a "slow" query.
-- Suggest 2
( Max_used_connections / max_connections ) = 152 / 151 = 100.7%
-- Peak % of connections
-- increase max_connections (now 151) and/or decrease wait_timeout (now 28800). Or speed up queries.
( Connections ) = 11,987,448 / 1725103 = 6.9 /sec
-- Connections
-- Increase wait_timeout (now 28800); use pooling?
( Connection_errors_accept + Connection_errors_internal + Connection_errors_peer_address + Connection_errors_select + Connection_errors_tcpwrap ) = 0 + 26 + 0 + 0 + 0 = 26
-- Connection errors other than max_connections.
-- For more info, see SHOW GLOBAL STATUS LIKE 'Connection_errors%'
Abnormally small:
Created_tmp_files = 0.094 /HR
innodb_spin_wait_delay = 4
Abnormally large:
Aria_pagecache_writes = 34 /sec
Aria_transaction_log_syncs = 25,641
Com_show_warnings = 40 /HR
Connection_errors_internal = 0.054 /HR
Handler_read_key = 85109 /sec
Handler_tmp_update = 839 /sec
Innodb_buffer_pool_read_requests = 675158 /sec
Innodb_buffer_pool_read_requests / (Innodb_buffer_pool_read_requests + Innodb_buffer_pool_reads ) = 100.0%
Innodb_rows_updated = 356 /sec
performance_schema_max_cond_classes = 90
Abnormal strings:
Innodb_have_punch_hole = OFF
aria_recover_options = BACKUP,QUICK
disconnect_on_expired_password = OFF
ft_boolean_syntax = + -><()~*:
innodb_fast_shutdown = 1
log_output = TABLE
myisam_stats_method = NULLS_UNEQUAL
old_alter_table = DEFAULT
optimizer_trace = enabled=off