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