-- A write buffer that holds no batch (a transaction that inserted and rolled back, the only row of the buffer) has no batch array: the aggregate scan asks the buffer -- for its batches all the same, and a copy of zero bytes from a NULL pointer is undefined (UBSan halts the backend and the server restarts: the sanitizer build of the full -- tier fails on it, and so does every job that runs in the cluster while it recovers). CREATE EXTENSION pg_sift; SET max_parallel_workers_per_gather = 0; SET sift.enable_agg = on; SET enable_seqscan = off; SET enable_indexscan = off; SET enable_bitmapscan = off; SET enable_indexonlyscan = off; CREATE TABLE we (id int PRIMARY KEY, g int, v int) WITH (autovacuum_enabled = off); INSERT INTO we SELECT i, i % 5, i FROM generate_series(1, 20000) i; CREATE INDEX we_col ON we USING sift_col (id, g, v); NOTICE: sift_col index "we_col": 1 automatic choice (track_changes) DETAIL: track_changes = id HINT: Reasons, costs and how to turn each off: SELECT * FROM sift.index_choices('we_col'); BEGIN; INSERT INTO we VALUES (500000, 1, 1); ROLLBACK; EXPLAIN (COSTS OFF) SELECT g, count(*) FROM we WHERE g < 3 GROUP BY g; QUERY PLAN ------------------------------- Custom Scan (SiftAgg) Index: we_col Filters: g < 3 Group Keys: g Pushed Aggregates: count(*) (5 rows) SELECT g, count(*), sum(v) FROM we WHERE g < 3 GROUP BY g ORDER BY g; g | count | sum ---+-------+---------- 0 | 4000 | 40010000 1 | 4000 | 39994000 2 | 4000 | 39998000 (3 rows) SELECT count(*), sum(v) FROM we WHERE g = 4; count | sum -------+---------- 4000 | 40006000 (1 row) DROP TABLE we; DROP EXTENSION pg_sift;