数据库
首页 > 数据库> > 048.PGSQL-系统表pg_stat_all_tables、pg_class、pg_tables、pg_indexes、pg_attribute

048.PGSQL-系统表pg_stat_all_tables、pg_class、pg_tables、pg_indexes、pg_attribute

作者:互联网

pg_stat_all_tables、pg_class、pg_tables、pg_indexes、pg_attribute

 

查看表大小

select pt.schemaname||'.'||pt.tablename,pg_relation_filepath(pt.schemaname||'.'||pt.tablename),
       pg_table_size(pt.schemaname||'.'||pt.tablename),
       pg_relation_size(pt.schemaname||'.'||pt.tablename),
       pg_total_relation_size(pt.schemaname||'.'||pt.tablename),
       pi.schemaname||'.'||pi.indexname,pg_relation_filepath(pi.schemaname||'.'||pi.indexname),
       pg_relation_size(pi.schemaname||'.'||pi.indexname),--指定的单个索引
       pg_indexes_size(pi.schemaname||'.'||pi.tablename) --表上的所有索引
 from pg_tables pt
      left outer join pg_indexes pi 
                   on pt.schemaname||'.'||pt.tablename = pi.schemaname||'.'||pi.tablename
where 1=1
  and pt.schemaname='myschema'
  and pt.tablename='o_ls_test'
 

 

标签:tables,stat,pt,tablename,relation,pg,schemaname,pi
来源: https://www.cnblogs.com/star521/p/15096298.html