Created
April 7, 2025 06:49
-
-
Save leecrosdale/94e757d8daf781467543d5f1f5251496 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Set how much RAM (in GB) your server has | |
SET @total_ram_gb = 8; | |
-- Convert to bytes | |
SET @ram_bytes = @total_ram_gb * 1024 * 1024 * 1024; | |
-- Run the check | |
SELECT | |
VARIABLE_NAME, | |
VARIABLE_VALUE, | |
CASE | |
WHEN VARIABLE_NAME = 'innodb_buffer_pool_size' | |
AND VARIABLE_VALUE < @ram_bytes * 0.5 | |
THEN CONCAT('TOO LOW (Recommended: ', ROUND(@total_ram_gb * 0.5), 'G - ', ROUND(@total_ram_gb * 0.75), 'G)') | |
WHEN VARIABLE_NAME = 'innodb_buffer_pool_size' | |
AND VARIABLE_VALUE >= @ram_bytes * 0.5 | |
THEN 'OK' | |
WHEN VARIABLE_NAME = 'tmp_table_size' | |
AND VARIABLE_VALUE < 256 * 1024 * 1024 | |
THEN 'TOO LOW (Recommended: 256M - 512M)' | |
WHEN VARIABLE_NAME = 'max_heap_table_size' | |
AND VARIABLE_VALUE < 256 * 1024 * 1024 | |
THEN 'TOO LOW (Recommended: 256M - 512M)' | |
WHEN VARIABLE_NAME = 'query_cache_size' | |
AND VARIABLE_VALUE > 128 * 1024 * 1024 | |
THEN 'TOO HIGH (Recommended: 64M - 128M or DISABLE if using InnoDB)' | |
ELSE 'OK' | |
END AS Recommendation | |
FROM | |
performance_schema.global_variables | |
WHERE | |
VARIABLE_NAME IN ( | |
'innodb_buffer_pool_size', | |
'tmp_table_size', | |
'max_heap_table_size', | |
'query_cache_size' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment