Shows the size of every postgres database column:
CREATE FUNCTION tc_column_size(table_name text, column_name text)
RETURNS BIGINT AS
$$
declare response BIGINT;
BEGIN
EXECUTE 'select sum(pg_column_size(t."' || column_name || '")) from "' || table_name || '" t ' into response;
return response;
END;
$$
LANGUAGE plpgsql;
SELECT
z.table_name,
z.column_name,
pg_size_pretty(z.size)
FROM (
SELECT
table_name,
column_name,
tc_column_size(table_name, column_name) size
FROM
information_schema.columns
WHERE
table_schema = 'public') AS z
WHERE
size IS NOT NULL
-- and z.table_name = 'my_table' -- <--- uncomment to filter a table
ORDER BY
z.size DESC;