Last active
October 30, 2020 11:38
-
-
Save mgttt/5b5fe34923808cc70bc09d55cc0ce86c to your computer and use it in GitHub Desktop.
mysql table size etc
This file contains 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 characters
SELECT TABLE_SCHEMA,TABLE_NAME,TABLE_ROWS,DATA_LENGTH,INDEX_LENGTH FROM information_schema.TABLES | |
where DATA_LENGTH+INDEX_LENGTH >0 and TABLE_SCHEMA not in ('mysql','sys','information_schema'); | |
select * from information_schema.TABLES limit 1; |
select CONCAT(TABLE_SCHEMA,'.',TABLE_NAME) TBL, COLUMN_NAME as col
, DATA_TYPE as type
from information_schema.columns where TABLE_SCHEMA not in ('mysql','sys','information_schema','performance_schema') limit 100;
select count(*) from information_schema.columns where TABLE_SCHEMA not in ('mysql','sys','information_schema','performance_schema')
TODO: GROUP BY COL
=>
if count(*)>ct_manually then:
manually tick needed; or sampling
else:
count (<max_count) or manually tick => do group table :
call build_col_rpt(col)
SELECT table_schema, table_name, engine
, table_rows,update_time
,avg_row_length
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','sys','information_schema','performance_schema')
ORDER BY table_rows * avg_row_length
DESC;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SELECT CONCAT(TABLE_SCHEMA,'.',TABLE_NAME) TBL,TABLE_ROWS,DATA_LENGTH,INDEX_LENGTH,UPDATE_TIME FROM information_schema.TABLES where DATA_LENGTH+INDEX_LENGTH >0 and TABLE_SCHEMA not in ('mysql','sys','information_schema','performance_schema');