首页 > 数据库技术 > 详细

POSTGRESQL 查看数据库 数据表大小

时间:2014-08-19 18:06:05      阅读:1784      评论:0      收藏:0      [点我收藏+]

标签:des   class   style   数据   com   log   数据库   si   

1、查看数据库大小:

select pg_database_size(‘log_analysis‘);

***(Single step mode: verify command)*******************************************
select pg_database_size(log_analysis);
***(press return to proceed or enter x and return to cancel)********************

 pg_database_size 
------------------
         23799992
(1 row)

2、select pg_database.datname, pg_size_pretty (pg_database_size(pg_database.datname)) AS size from pg_database; 

log_analysis=# select pg_database.datname, pg_size_pretty (pg_database_size(pg_database.datname)) AS size from pg_database; 
***(Single step mode: verify command)*******************************************
select pg_database.datname, pg_size_pretty (pg_database_size(pg_database.datname)) AS size from pg_database;
***(press return to proceed or enter x and return to cancel)********************

   datname    |  size   
--------------+---------
 template1    | 6594 kB
 template0    | 6457 kB
 postgres     | 6586 kB
 b2c_product  | 27 GB
 spider       | 11 MB
 crm          | 54 MB
 log_analysis | 23 MB
(7 rows)

log_analysis=# 

3、按顺序查看索引

select indexrelname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_indexes where schemaname=‘public‘ order by pg_relation_size(relid) desc;

log_analysis=# select indexrelname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_indexes where schemaname=public order by pg_relation_size(relid) desc;
***(Single step mode: verify command)*******************************************
select indexrelname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_indexes where schemaname=public order by pg_relation_size(relid) desc;
***(press return to proceed or enter x and return to cancel)********************

                        indexrelname                        | pg_size_pretty 
------------------------------------------------------------+----------------
 pk_dim_sight_area                                          | 184 kB
 idx_area_dim_sight_area                                    | 184 kB
 idx_city_dim_sight_area                                    | 184 kB
 idx_country_dim_sight_area                                 | 184 kB
 idx_region_dim_sight_area                                  | 184 kB
 pk_dim_page_type                                           | 8192 bytes
 cpc_supplier_sight_daily_pkey                              | 0 bytes

4、查看所有表的大小

select relname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_tables where schemaname=‘public‘ order by pg_relation_size(relid) desc;

log_analysis=# select relname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_tables where schemaname=public order by pg_relation_size(relid) desc;
***(Single step mode: verify command)*******************************************
select relname, pg_size_pretty(pg_relation_size(relid)) from pg_stat_user_tables where schemaname=public order by pg_relation_size(relid) desc;
***(press return to proceed or enter x and return to cancel)********************

                    relname                     | pg_size_pretty 
------------------------------------------------+----------------
 dim_sight_area                                 | 184 kB
 dim_page_type                                  | 8192 bytes
 wirelessapi_log_2014_08_08                     | 0 bytes
 trace_log_2014_08_04                           | 0 bytes
 dm_mobile                                      | 0 bytes
 trace_log_2014_07_14                           | 0 bytes

 

POSTGRESQL 查看数据库 数据表大小,布布扣,bubuko.com

POSTGRESQL 查看数据库 数据表大小

标签:des   class   style   数据   com   log   数据库   si   

原文:http://www.cnblogs.com/liqiu/p/3922288.html

(0)
(0)
   
举报
评论 一句话评论(0
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号