-- -- src/test/performance/cfs/datashape_toast.sql -- -- Phase 13 / A13.2 -- data-shape benchmark: TOAST-heavy (> 1 MB) values. -- -- Each row holds a single 1 MB text value. Heap pages themselves stay small -- (pointers), so the real compression happens in the TOAST relation, which -- inherits the main table's CFS policy (A5.4). This script therefore reports -- sizes split across main fork and TOAST. -- -- psql -v rows=200 -f datashape_toast.sql DROP TABLE IF EXISTS ds_toast_plain; DROP TABLE IF EXISTS ds_toast_cfs; CREATE TABLE ds_toast_plain (id int primary key, payload text); SELECT format('CREATE TABLE ds_toast_cfs (id int primary key, payload text) WITH (algorithm=%L)', :'algo')\gexec INSERT INTO ds_toast_plain SELECT g, repeat('toast-' || (g % 10), 150000) FROM generate_series(1, :rows) g; INSERT INTO ds_toast_cfs SELECT * FROM ds_toast_plain; CHECKPOINT; SELECT 'ds_toast' AS shape, pg_size_pretty(pg_relation_size('ds_toast_plain')) AS plain_main, pg_size_pretty(pg_total_relation_size('ds_toast_plain') - pg_relation_size('ds_toast_plain')) AS plain_toast, pg_size_pretty(pg_total_relation_size('ds_toast_cfs') - pg_relation_size('ds_toast_cfs')) AS cfs_toast, round((pg_total_relation_size('ds_toast_plain') - pg_relation_size('ds_toast_plain'))::numeric / NULLIF(pg_total_relation_size('ds_toast_cfs') - pg_relation_size('ds_toast_cfs'), 0), 2) AS toast_ratio;