# HG changeset patch # User Oleksandr Gavenko # Date 1602497834 -10800 # Node ID 41f79c1242b2b3f8a624601d049d10671e2d718c # Parent 27921ee2c781fbb949f9c0830ff9878a29c22232 Size of columns. diff -r 27921ee2c781 -r 41f79c1242b2 postgres.rst --- a/postgres.rst Mon Oct 12 01:08:41 2020 +0300 +++ b/postgres.rst Mon Oct 12 13:17:14 2020 +0300 @@ -465,12 +465,6 @@ where tbl.reltoastrelid = toast.oid order by toast.relpages desc; -Size of types:: - - SELECT pg_column_size(5::smallint); - SELECT pg_column_size(5::int); - SELECT pg_column_size(5::bigint); - Index size:: SELECT pg_indexes_size('my_ix'); @@ -488,6 +482,19 @@ where i.relkind = 'i' order by pg_relation_size(i.oid) desc; +Size of types:: + + SELECT pg_column_size(5::smallint); + SELECT pg_column_size(5::int); + SELECT pg_column_size(5::bigint); + +Size of column:: + + SELECT sum(pg_column_size(col)) FROM tbl; + +Total of all ``pg_column_size`` is less then ``pg_relation_size`` because table is using pages to +store rows and we might have gaps inside pages. + https://www.postgresql.org/docs/9.6/functions-admin.html Database Object Management Functions. https://wiki.postgresql.org/wiki/Disk_Usage