Last active
December 12, 2024 10:23
-
-
Save habedi/f93ee3de6622acc366fc0ff06b61b279 to your computer and use it in GitHub Desktop.
Revisions
-
habedi revised this gist
Dec 12, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ -- Note that numbers are estimates, so the exact number of rows or index size might slightly differ from the number shown -- For MySQL or MariaDB select table_name as `table name`, -
habedi revised this gist
Dec 12, 2024 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,8 @@ select from information_schema.tables where -- table_schema = coalesce(:schema_name, 'services') -- Doesn't work in `mysql` table_schema = 'services' order by `total size (gb)` desc; @@ -26,7 +27,7 @@ from join pg_namespace n on n.oid = c.relnamespace where -- n.nspname = coalesce(:schema_name, 'services') -- Doesn't work in `psql` n.nspname = 'services' -- replace with your schema name and c.relkind = 'r' -- only regular tables order by -
habedi revised this gist
Dec 12, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,8 @@ where order by `total size (gb)` desc; -------------------------------------------------------------------------------------------------------------------- -- For PostgreSQL select c.relname as "table name", -
habedi renamed this gist
Dec 12, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
habedi revised this gist
Dec 12, 2024 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ -- For MySQL or MariaDB select table_name as `table name`, table_rows as `row count`, @@ -10,3 +11,21 @@ where table_schema = coalesce(:schema_name, 'services') order by `total size (gb)` desc; -- For PostgreSQL select c.relname as "table name", coalesce(nullif(c.reltuples, -1), 0)::bigint as "row count", round(pg_table_size(c.oid) / (1024.0 * 1024 * 1024), 2) as "data size (gb)", round(pg_indexes_size(c.oid) / (1024.0 * 1024 * 1024), 2) as "index size (gb)", round(pg_total_relation_size(c.oid) / (1024.0 * 1024 * 1024), 2) as "total size (gb)" from pg_class c join pg_namespace n on n.oid = c.relnamespace where -- n.nspname = coalesce(:schema_name, 'services') -- Doesn't work in psql n.nspname = 'services' -- replace with your schema name and c.relkind = 'r' -- only regular tables order by "total size (gb)" desc; -
habedi revised this gist
Dec 10, 2024 . No changes.There are no files selected for viewing
-
habedi created this gist
Dec 9, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ select table_name as `table name`, table_rows as `row count`, round(data_length / (1024 * 1024 * 1024), 2) as `data size (gb)`, round(index_length / (1024 * 1024 * 1024), 2) as `index size (gb)`, round((data_length + index_length) / (1024 * 1024 * 1024), 2) as `total size (gb)` from information_schema.tables where table_schema = coalesce(:schema_name, 'services') order by `total size (gb)` desc;