-- -- src/test/performance/cfs/datashape_text.sql -- -- Phase 13 / A13.2 -- data-shape benchmark: highly repetitive text. -- -- The classic best case for page-level compression: long runs of the same -- token. Shows how close CFS gets to the codec's own stream ratio. -- -- psql -v rows=5000 -f datashape_text.sql DROP TABLE IF EXISTS ds_text_plain; DROP TABLE IF EXISTS ds_text_cfs; CREATE TABLE ds_text_plain (id int primary key, payload text); SELECT format('CREATE TABLE ds_text_cfs (id int primary key, payload text) WITH (algorithm=%L)', :'algo')\gexec INSERT INTO ds_text_plain SELECT g, repeat('ab', 400) FROM generate_series(1, :rows) g; INSERT INTO ds_text_cfs SELECT * FROM ds_text_plain; CHECKPOINT; SELECT 'ds_text' AS shape, pg_size_pretty(pg_total_relation_size('ds_text_plain')) AS plain_size, pg_size_pretty(pg_total_relation_size('ds_text_cfs')) AS cfs_size, round(pg_total_relation_size('ds_text_plain')::numeric / NULLIF(pg_total_relation_size('ds_text_cfs'), 0), 2) AS ratio;