原 GreenPlum查询数据库中前几张大表
前50张大表,根据行数倒序排序
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | SELECT t.table_catalog as db, n.nspname AS schemaname, c.relname, c.reltuples::numeric as rowcount, pg_size_pretty(pg_table_size ( '"' || nspname || '"."' || relname || '"' )) AS table_size, pg_size_pretty(pg_indexes_size ( '"' || nspname || '"."' || relname || '"' )) AS indexes_size, pg_size_pretty (pg_total_relation_size ( '"' || nspname || '"."' || relname || '"' )) AS total_size --,pg_relation_filepath(table_name) filepath FROM pg_class C LEFT JOIN pg_namespace N ON ( N.oid = C.relnamespace ) left join information_schema.tables t on (n.nspname= t.table_schema and c.relname=t."table_name" ) WHERE nspname NOT IN ( 'pg_catalog', 'information_schema','gp_toolkit' ) AND relkind in ('r','p') ORDER BY rowcount DESC LIMIT 50; |