--- 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