-- create table and indexes (one btree used by the updates later)
create table brin_test (id int, a int, b bigint, c float, d double precision, e uuid);
create index on brin_test (id);
create index on brin_test using brin (a) with (pages_per_range=16);
create index on brin_test using brin (b) with (pages_per_range=16);
create index on brin_test using brin (c) with (pages_per_range=16);
create index on brin_test using brin (d) with (pages_per_range=16);
create index on brin_test using brin (e) with (pages_per_range=16);

-- leave there 10% free space for the updates
alter table brin_test set (fillfactor = 90);

-- insert data (let it run for a while)
insert into brin_test select i, mod(i,10000), mod(i,10000), mod(i,10000)/25, mod(i,10000)/25, md5((mod(i,10000)/25)::text)::uuid from generate_series(1,100000) s(i) \watch 0.1

-- update random subsets of data (every time about 0.001%)
-- the update only slightly tweaks the values, to not make the ranges extremely wide
update brin_test set a = a + (50 - 100*random()), b = b + (100 - 200 * random()), c = c + (10 - 20 * random()), d = d + (25 - 50 * random()), e = md5(((random() * 10000)/25)::text)::uuid where id = (100000 * random())::int \watch 10
