Skip to content

Instantly share code, notes, and snippets.

@willpower232
Last active February 3, 2020 14:27
Show Gist options
  • Save willpower232/a9a9e54fa064f34f558f606106fd99b6 to your computer and use it in GitHub Desktop.
Save willpower232/a9a9e54fa064f34f558f606106fd99b6 to your computer and use it in GitHub Desktop.
get the Postal database size for each mail server
SELECT sizes.dbname, orgs.`name` AS org, servers.`name` AS `server`, sizes.size
FROM (
SELECT substring(sizes.table_schema, 15) AS fakeid, sizes.table_schema AS dbname, ROUND(SUM(sizes.data_length + sizes.index_length) / 1024 / 1024, 1) AS size
FROM information_schema.`TABLES` AS sizes
GROUP BY sizes.table_schema
) AS sizes, postal.servers AS servers, postal.organizations AS orgs
WHERE servers.id = sizes.fakeid
AND servers.organization_id = orgs.id
ORDER BY org, `server`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment