Using Postgres to return the size of a table
SELECT pg_size_pretty(pg_table_size('zlimitreacjed_1'));
returns '1632 kb'....is there anyway to return this value as MB as opposed to kb's?
Judging by the documentation here, pg_size_pretty automatically adjusts as appropriate. If you want to use megs regardless, you could just use
SELECT pg_table_size('zlimitreacjed_1') / 1024 /1024 || 'MB';
pg_table_size returns bytes, so just divide it by 1024 a bunch of times, depending on what you want (once for kb, twice for mb, thrice for gb and so on).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With