Used DBsize query

Paulo Santos santosp at fedoraproject.org
Wed Jul 25 08:19:26 UTC 2007


Hey guys,

Since yesterday some of you were wondering how much space the DBs were
using, i searched the query that our DBAs use, for that information.
See if this is useful for anyone:

(this requires MySQL5)

SELECT
s.schema_name AS 'Schema',
IFNULL(ROUND((SUM(t.data_length)+SUM(t.index_length)) /1024/1024,2),0.00) AS
'Total Mb',
IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free
))/1024/1024,2),0.00) AS 'Mb Used',
IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00) AS 'Mb Free',
IFNULL(ROUND((((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))
/((SUM(t.data_length)+SUM(t.index_length)))*100),2),0)
AS 'Pct Used',
COUNT(table_name) AS Tables
FROM INFORMATION_SCHEMA.SCHEMATA s
LEFT JOIN INFORMATION_SCHEMA.TABLES t ON s.schema_name = t.table_schema
GROUP BY s.schema_name;

I also have one for oracle, much more complete...


Thanks,
Paulo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-infrastructure-list/attachments/20070725/dc4c8571/attachment.htm>


More information about the Fedora-infrastructure-list mailing list