0

this is my current table size:

select pg_size_pretty(pg_relation_size('items'));

 pg_size_pretty 
----------------
210 GB

but when I using pg_databse_size, it shows 1901GB

SELECT pg_size_pretty (pg_database_size ('mydb'));

 pg_size_pretty 
----------------
 1901 GB
(1 row)

I have been checking all tables, and the items table is the biggest.

My questions is: how to make me understand this situation? Could you explain to me about this condition? Or give me a link to make me understand it.

  • 1
    What are you asking ? The Db size is clearly bigger than a table ? https://www.postgresql.org/docs/11/static/functions-admin.html – VynlJunkie Oct 29 '18 at 15:08
  • @Mokadillion, my question is: I have 100 tables and all 99 tables only has arround 90GB, and items table has 210GB, but when I did checking the database size, it shows 1901GB. why it could be happen? and how to check where is the 1901- 300GB ( items and others tables) ? – qwertynesia Oct 29 '18 at 15:12
  • database size will likely be the size of the entire cluster, not just the objects in your database, so everything in the /data/ directory – VynlJunkie Oct 29 '18 at 15:17
  • 4
    `pg_relation_size()` doesn't take indexes into account, `pg_database_size()` does –  Oct 29 '18 at 15:17
  • I got it from here: https://stackoverflow.com/a/41991566/3728442 .thanks all – qwertynesia Oct 29 '18 at 15:22
  • Possible duplicate of [What's the difference between pg\_table\_size, pg\_relation\_size & pg\_total\_relation\_size? (PostgreSQL)](https://stackoverflow.com/questions/41991380/whats-the-difference-between-pg-table-size-pg-relation-size-pg-total-relatio) – cske Oct 29 '18 at 19:38

0 Answers0