-- the segments a merge writes are cut to what maintenance_work_mem holds (the writer keeps the key and address of every row of a global order until the last -- unit of the segment is in): a small setting makes partitions of a few MB, a large one a single segment CREATE EXTENSION pg_sift; SET client_min_messages = warning; SET max_parallel_maintenance_workers = 4; SET sift.col_auto_merge_wal_pct = 0; -- the build merges its own peers (col_build_standby_space): not here, which leaves the peers this test merges under a small maintenance_work_mem SET sift.col_auto_merge_fragmentation = 1000; CREATE TABLE mm (id int, cust int, amt int, q int) WITH (autovacuum_enabled = false); INSERT INTO mm SELECT i, ((i::bigint * 7919) % 20000)::int, hashint8(i) % 1000000, hashint8(i + 7) FROM generate_series(1, 800000) i; VACUUM (FREEZE, ANALYZE) mm; CREATE INDEX mm_idx ON mm USING sift_col (id, cust, amt, q) WITH (key_cut = 'cust'); SELECT count(*) > 1 AS peers, sum(bytes) > 6 * 1024 * 1024 AS over_the_floor FROM sift.col_segments('mm_idx') WHERE kind = 'immutable'; peers | over_the_floor -------+---------------- t | t (1 row) SET maintenance_work_mem = '1MB'; SELECT sift.col_merge('mm_idx', true); col_merge ----------- 1 (1 row) SELECT count(*) > 1 AS partitions, max(bytes) < 4 * 1024 * 1024 AS each_under_the_floor FROM sift.col_segments('mm_idx') WHERE kind = 'immutable'; partitions | each_under_the_floor ------------+---------------------- t | t (1 row) SELECT sift.col_maintenance_due('mm_idx', false) IS NULL AS partitions_are_left_alone; partitions_are_left_alone --------------------------- t (1 row) SELECT sift.col_verify('mm_idx', true); col_verify ------------ (1 row) -- one process: from 12 MB of segments the workers would write a segment each (col_rewrite_slices) SET max_parallel_maintenance_workers = 0; SET maintenance_work_mem = '1GB'; SELECT sift.col_merge('mm_idx', true); col_merge ----------- 1 (1 row) SELECT count(*) AS segments FROM sift.col_segments('mm_idx') WHERE kind = 'immutable'; segments ---------- 1 (1 row) SELECT sift.col_verify('mm_idx', true); col_verify ------------ (1 row) DROP TABLE mm; DROP EXTENSION pg_sift;