#10568·timescaledb

bloom filter not used to check UNIQUE constraint w/o ON CONFLICT action

Author: akuzmCreated Sep 8, 2026Updated Sep 8, 2026
LabelsColumnstore
-- Inserting into a compressed chunk with a unique index: the sparse bloom
-- index prunes the batches checked for conflicts only when the INSERT has
-- an ON CONFLICT clause; a plain INSERT decompresses the batches instead.

create table kennel_checkins(checkin_time timestamptz not null, dog_tag text);
select create_hypertable('kennel_checkins', 'checkin_time');
create unique index on kennel_checkins(dog_tag, checkin_time);
alter table kennel_checkins set (timescaledb.compress,
    timescaledb.compress_orderby = 'checkin_time');

insert into kennel_checkins
select '2026-01-01'::timestamptz + interval '1 second' * i, 'tag-' || i
from generate_series(1, 10) i;
select compress_chunk(show_chunks('kennel_checkins'));

-- baseline: with ON CONFLICT the conflict check prunes the batch using
-- the bloom index, without decompressing it
begin;
explain (analyze, costs off, buffers off, summary off, timing off)
insert into kennel_checkins values ('2026-01-01 00:00:05.5', 'setter-rex')
on conflict (dog_tag, checkin_time) do nothing;
-- shows: Batches pruned by bloom: 1
rollback;

-- the same insert without ON CONFLICT
explain (analyze, costs off, buffers off, summary off, timing off)
insert into kennel_checkins values ('2026-01-01 00:00:05.5', 'setter-rex');
-- shows: Batches filtered after decompression: 1, no bloom pruning;
-- the batch was decompressed for the same unique-constraint check