Skip to content

Instantly share code, notes, and snippets.

@toddsiegel
Created March 9, 2014 19:52
Show Gist options
  • Save toddsiegel/9453514 to your computer and use it in GitHub Desktop.
Save toddsiegel/9453514 to your computer and use it in GitHub Desktop.
Queries To Help with Tuning MySQL
-- Determine size of databases
-- Source: http://stackoverflow.com/questions/1733507/how-to-get-size-of-mysql-database
SELECT table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
-- Size in MB of the innodb_buffer_pool_size. Default is 128 MB.
-- More here: http://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html#sysvar_innodb_buffer_pool_size
SELECT @@innodb_buffer_pool_size / 1024 / 1024
-- Actual pages of InnoDB data reside in the InnoDB Buffer Pool.\
-- Source: http://dba.stackexchange.com/questions/27328/how-large-should-be-mysql-innodb-buffer-pool-size
SELECT (PagesData*PageSize)/POWER(1024,3) DataGB FROM
(SELECT variable_value PagesData
FROM information_schema.global_status
WHERE variable_name='Innodb_buffer_pool_pages_data') A,
(SELECT variable_value PageSize
FROM information_schema.global_status
WHERE variable_name='Innodb_page_size') B;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment