POSTGRESQL 查看資料庫 資料表大小

來源:互聯網
上載者:User

標籤:des   style   blog   color   os   io   資料   ar   

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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.