Skip to content

Instantly share code, notes, and snippets.

@sumodirjo
Created August 17, 2022 09:28
Show Gist options
  • Save sumodirjo/c872d51c64528f4d71ab58f67d34fac4 to your computer and use it in GitHub Desktop.
Save sumodirjo/c872d51c64528f4d71ab58f67d34fac4 to your computer and use it in GitHub Desktop.

MySQL Notes

Useful Queries

Size Specific Table

SELECT
	table_name AS `Table`,
	round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM
	information_schema.TABLES
WHERE
	table_schema = 'db_name'
	AND table_name = 'table_name';

Size All Table (DESC)

SELECT
	table_schema AS `Database`,
	table_name AS `Table`,
	round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM
	information_schema.TABLES
ORDER BY
	(data_length + index_length)
	DESC;

Readings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment