POSTGRESQL View database data table size

Source: Internet
Author: User

1. Check the database size:

Select Pg_database_size (' log_analysis ');

(Single Step mode:verify command) *******************************************select pg_database_size ( ' log_analysis ' ); return return to cancel) ********************------------------         23799992(  1 Row)

2, select Pg_database.datname, Pg_size_pretty (Pg_database_size (pg_database.datname)) as size from pg_database;

log_analysis=#SelectPg_database.datname, Pg_size_pretty (Pg_database_size (pg_database.datname)) as size frompg_database;(Single Step mode:verify command) *******************************************SelectPg_database.datname, Pg_size_pretty (Pg_database_size (pg_database.datname)) as size frompg_database;(PressreturnTo proceed or enter X andreturnTo cancel) ********************Datname|size--------------+---------template1|6594KB template0|6457KB Postgres|6586KB b2c_product| -GB Spider| OneMB CRM| WuMB log_analysis| atMB (7rows) log_analysis=#

3. View the index sequentially

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=#SelectIndexrelname, Pg_size_pretty (Pg_relation_size (relid)) fromPg_stat_user_indexeswhereSchemaname=' Public'ORDER by Pg_relation_size (relid) desc;(Single Step mode:verify command) *******************************************SelectIndexrelname, Pg_size_pretty (Pg_relation_size (relid)) fromPg_stat_user_indexeswhereSchemaname=' Public'ORDER by Pg_relation_size (relid) desc;(PressreturnTo proceed or enter X andreturnTo cancel) ********************Indexrelname|Pg_size_pretty------------------------------------------------------------+----------------Pk_dim_sight_area|184KB Idx_area_dim_sight_area|184KB Idx_city_dim_sight_area|184KB Idx_country_dim_sight_area|184KB Idx_region_dim_sight_area|184KB Pk_dim_page_type|8192bytes Cpc_supplier_sight_daily_pkey|0bytes

4. View the size of all tables

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=#SelectRelname, Pg_size_pretty (Pg_relation_size (relid)) fromPg_stat_user_tableswhereSchemaname=' Public'ORDER by Pg_relation_size (relid) desc;(Single Step mode:verify command) *******************************************SelectRelname, Pg_size_pretty (Pg_relation_size (relid)) fromPg_stat_user_tableswhereSchemaname=' Public'ORDER by Pg_relation_size (relid) desc;(PressreturnTo proceed or enter X andreturnTo cancel) ********************Relname|Pg_size_pretty------------------------------------------------+----------------Dim_sight_area|184KB Dim_page_type|8192bytes wirelessapi_log_2014_08_08|0bytes Trace_log_2014_08_04|0bytes Dm_mobile|0bytes Trace_log_2014_07_14|0bytes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.