How to estimate the size of one column in a Postgres table?
Slight improvement on the accepted answer: pretty print the size and use pg_total_relation_size to be more accurate.
select
pg_size_pretty(sum(pg_column_size(column_name))) as total_size,
pg_size_pretty(avg(pg_column_size(column_name))) as average_size,
sum(pg_column_size(column_name)) * 100.0 / pg_total_relation_size('table_name') as percentage
from table_name;
select
sum(pg_column_size(the_text_column)) as total_size,
avg(pg_column_size(the_text_column)) as average_size,
sum(pg_column_size(the_text_column)) * 100.0 / pg_relation_size('t') as percentage
from t;