clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2591601 fiddles created (45738 in the last week).

CREATE TABLE tbl (id int, col text); INSERT INTO tbl(id, col) VALUES (1, rpad(md5('non_random'::text), 100, md5('non_random'::text))) , (2, rpad(md5('non_random'::text), 1000, md5('non_random'::text))) , (3, rpad(md5('non_random'::text), 10000, md5('non_random'::text))) , (4, rpad(md5('non_random'::text), 100000, md5('non_random'::text))) , (5, rpad(md5('non_random'::text), 500000, md5('non_random'::text))) , (6, rpad(md5('non_random'::text), 1000000, md5('non_random'::text)));
6 rows affected
 hidden batch(es)


SELECT id, left(col, 10) || ' ...' AS col , length(col) AS char_length , pg_column_size(col) AS compressed , pg_column_size(col || '') AS uncompressed FROM tbl ORDER BY id;
id col char_length compressed uncompressed
1 67ad0f29fa ... 100 101 104
2 67ad0f29fa ... 1000 1004 1004
3 67ad0f29fa ... 10000 160 10004
4 67ad0f29fa ... 100000 1191 100004
5 67ad0f29fa ... 500000 5765 500004
6 67ad0f29fa ... 1000000 11487 1000004
 hidden batch(es)


SELECT pg_column_size(rpad(md5('non_random'::text), 1000000, md5('non_random'::text)));
pg_column_size
1000004
 hidden batch(es)