I’m coming to Postgres from Oracle and looking for a way to find the table and index size in terms of bytes/MB/GB/etc, or even better the size for all tables. In Oracle I had a nasty long query that looked at user_lobs and user_segments to give back an answer.
I assume in Postgres there’s something I can use in the information_schema tables, but I’m not seeing where.
Try the Database Object Size Functions. An example:
For all tables, something along the lines of:
Edit: Here’s the query submitted by @phord, for convenience:
I’ve modified it slightly to use
pg_table_size()to include metadata and make the sizes add up.