...
코드 블럭 | ||||
---|---|---|---|---|
| ||||
# su postgres bash-4.2$ psql psql (10.17) postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ------------+------------+-----------+---------+-------+--------------------------- esmond | postgres | SQL_ASCII | C | C | =Tc/postgres + | | | | | postgres=CTc/postgres + | | | | | esmond=CTc/postgres pscheduler | pscheduler | SQL_ASCII | C | C | =Tc/pscheduler + | | | | | pscheduler=CTc/pscheduler postgres=# \c esmond You are now connected to database "esmond" as user "postgres". esmond=# \dt select esmond-# table_name, esmond-# pg_size_pretty(pg_relation_size(quote_ident(table_name))), esmond-# pg_relation_size(quote_ident(table_name)) esmond-# from information_schema.tables esmond-# where table_schema = 'public'; table_name | pg_size_pretty | pg_relation_size ----------------------------+----------------+------------------ django_migrations | 8192 bytes | 8192 ps_metadata_parameters | 8192 bytes | 8192 ps_networkelement_subject | 0 bytes | 0 django_content_type | 8192 bytes | 8192 auth_group_permissions | 0 bytes | 0 auth_group | 0 bytes | 0 auth_user | 8192 bytes | 8192 auth_user_groups | 0 bytes | 0 auth_permission | 8192 bytes | 8192 auth_user_user_permissions | 0 bytes | 0 django_admin_log | 0 bytes | 0 ps_p2p_subject | 8192 bytes | 8192 useripaddress | 0 bytes | 0 ps_metadata | 8192 bytes | 8192 ps_event_types | 32 kB | 32768 authtoken_token | 8192 bytes | 8192 django_session | 0 bytes | 0 (17 rows) esmond=# \c pscheduler You are now connected to database "pscheduler" as user "postgres". pscheduler=# select pscheduler-# table_name, pscheduler-# pg_size_pretty(pg_relation_size(quote_ident(table_name))), pscheduler-# pg_relation_size(quote_ident(table_name)) pscheduler-# from information_schema.tables pscheduler-# where table_schema = 'public'; table_name | pg_size_pretty | pg_relation_size ---------------------------+----------------+------------------ scheduling_class | 8192 bytes | 8192 archive_default | 16 kB | 16384 tool_test | 8192 bytes | 8192 table_version | 8192 bytes | 8192 heartbeat | 528 kB | 540672 auth_key_type | 8192 bytes | 8192 auth_key | 0 bytes | 0 control | 8192 bytes | 8192 queries | 0 bytes | 0 heartbeat_full | 0 bytes | 0 archiving_eligible | 0 bytes | 0 schedule | 0 bytes | 0 archiver_test | 0 bytes | 0 heartbeat_json | 0 bytes | 0 http_queue | 48 kB | 49152 test | 440 kB | 450560 tool | 696 kB | 712704 archiver_summary | 0 bytes | 0 context | 40 kB | 40960 run_conflictable | 0 bytes | 0 run_status | 0 bytes | 0 run_status_short | 0 bytes | 0 schedule_upcoming | 0 bytes | List of relations Schema | 0 schedule_runs_to_schedule | 0 bytes | Name | Type | Owner --------+----------------------------+-------+-------- public | auth_group 0 schedule_overlap | 0 bytes | table | esmond public | auth_group_permissions | table | esmond public | auth_permission0 run_state | table 8192 bytes | esmond public | auth_user 8192 task | 7552 kB | table | esmond public | auth_user_groups 7733248 configurables | table | esmond public | auth_user_user_permissions | table | esmond public | authtoken_token8192 bytes | | table | esmond public | django_admin_log 8192 run_latest | table | esmond public | django_content_type | 136 kB | table | esmond public | django_migrations |139264 tablearchiver | esmond public | django_session | table216 |kB esmond public | ps_event_types | | table | esmond221184 publicrun | ps_metadata | table | esmond public | ps_metadata_parameters388 MB | table | esmond public | ps_networkelement_subject | table | esmond406921216 publicarchiving | ps_p2p_subject | table | esmond 575 publicMB | useripaddress | | table | esmond602931200 (1732 rows) |
https://stackoverflow.com/questions/21738408/postgresql-list-and-order-tables-by-size