Database/PostgreSQL

[PostgreSQL] DB 및 Tablespace Size 확인

요체크다 2022. 10. 27. 23:42
반응형

PostgreSQL에서 DB 및 Tablespace Size 확인 시 아래 쿼리를 통해 조회가 가능합니다.

 

1) 특정 DB Size 확인

  # select * from pg_size_pretty(pg_database_size ('DB명'));

postgres=# select * from pg_size_pretty(pg_database_size ('postgres'));

 pg_size_pretty
----------------
 7255 kB
(1개 행)

 

2) 전체 DB Size 확인

  # select pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;

postgres=# SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;

     datname     |  size
-----------------+---------
 postgres        | 7255 kB

 

3) Tablespace Size 확인

  # select spcname, pg_size_pretty(pg_tablespace_size(spcname)) from pg_tablespace;

postgres=# select spcname, pg_size_pretty(pg_tablespace_size(spcname)) from pg_tablespace;

    spcname     | pg_size_pretty
----------------+----------------
 pg_default     | 1648 MB
 pg_global      | 6060 kB

 

 

반응형