pg_column_size()

A system function to show the size of data in a table column

pg_column_size() is a system function to show the size of data in a table column.

pg_column_size() was added in PostgreSQL 8.1 (commit a9236028).

Examples

postgres=# CREATE TABLE foo (id INT, val TEXT);
CREATE TABLE

postgres=# INSERT INTO foo values(1,'abc'), (2,'Hello World');
INSERT 0 2

postgres=# SELECT id, pg_column_size(id), val, pg_column_size(val) FROM foo;
 id | pg_column_size |     val     | pg_column_size 
----+----------------+-------------+----------------
  1 |              4 | abc         |              4
  2 |              4 | Hello World |             12
(2 rows)

Categories

Management / adminstration, System function

See also

pg_table_size(), pg indexes size(), pg total relation size(), pg_tablespace_size(), pg database size(),