maximum columns for brin bloom indexes

From: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
To: pgsql-hackers(at)postgresql(dot)org
Cc: tomas(dot)vondra(at)enterprisedb(dot)com
Subject: maximum columns for brin bloom indexes
Date: 2021-04-08 07:08:52
Message-ID: 20210408070852.GA8173@ahch-to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi everyone,

When testing brin bloom indexes I noted that we need to reduce the
PAGES_PER_RANGE parameter of the index to allow more columns on it.

Sadly, this could be a problem if you create the index before the table
grows, once it reaches some number of rows (i see the error as early as
1000 rows) it starts error out.

create table t1(i int, j int);

-- uses default PAGES_PER_RANGE=128
create index on t1 using brin(i int4_bloom_ops, j int4_bloom_ops ) ;

insert into t1
select random()*1000, random()*1000 from generate_series(1, 1000);
ERROR: index row size 8968 exceeds maximum 8152 for index "t1_i_j_idx"

if instead you create the index with a minor PAGES_PER_RANGE it goes
fine, in this case it works once you reduce it to at least 116

create index on t1 using brin(i int4_bloom_ops, j int4_bloom_ops )
with (pages_per_range=116);

so, for having:
two int columns - PAGES_PER_RANGE should be max 116
three int columns - PAGES_PER_RANGE should be max 77
one int and one timestamp - PAGES_PER_RANGE should be max 121

and so on

--
Jaime Casanova
Director de Servicios Profesionales
SystemGuards - Consultores de PostgreSQL

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2021-04-08 07:13:44 Re: Support tab completion for upper character inputs in psql
Previous Message Bharath Rupireddy 2021-04-08 07:07:46 Re: Set access strategy for parallel vacuum workers