pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17443: Select command does not use brin index when enable_seqscan = on
2+ messages / 2 participants
[nested] [flat]

* BUG #17443: Select command does not use brin index when enable_seqscan = on
@ 2022-03-21 02:44 PG Bug reporting form <noreply@postgresql.org>
  2022-03-21 09:21 ` Re: BUG #17443: Select command does not use brin index when enable_seqscan = on Julien Rouhaud <rjuju123@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2022-03-21 02:44 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: ronivaldolopes@hotmail.com

The following bug has been logged on the website:

Bug reference:      17443
Logged by:          Ronivaldo Lopes
Email address:      ronivaldolopes@hotmail.com
PostgreSQL version: 14.2
Operating system:   Linux Mint
Description:        

For the select command to use the brin index of the id2 field, I have to
change enable_seqscan = off

create temp table teste as
  select s::int as id1, s::int as id2, quote_ident('Nome ' || to_char(s,
'FM00000000'))::varchar(15) as nome
    from generate_series(1,10000000) x(s);

create index teste1 on teste (id1);
create index teste2 on teste using brin (id2);

EXPLAIN (analyze on, wal on, verbose on, format text)
  select id1 from teste where id1 = 1000000;
 
EXPLAIN (analyze on, wal on, verbose on, format text)
  select id2 from teste where id2 = 1000000;



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #17443: Select command does not use brin index when enable_seqscan = on
  2022-03-21 02:44 BUG #17443: Select command does not use brin index when enable_seqscan = on PG Bug reporting form <noreply@postgresql.org>
@ 2022-03-21 09:21 ` Julien Rouhaud <rjuju123@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Julien Rouhaud @ 2022-03-21 09:21 UTC (permalink / raw)
  To: ronivaldolopes@hotmail.com; pgsql-bugs@lists.postgresql.org

Hi,

On Mon, Mar 21, 2022 at 02:44:08AM +0000, PG Bug reporting form wrote:
> For the select command to use the brin index of the id2 field, I have to
> change enable_seqscan = off
>
> create temp table teste as
>   select s::int as id1, s::int as id2, quote_ident('Nome ' || to_char(s,
> 'FM00000000'))::varchar(15) as nome
>     from generate_series(1,10000000) x(s);
>
> create index teste1 on teste (id1);
> create index teste2 on teste using brin (id2);
>
> EXPLAIN (analyze on, wal on, verbose on, format text)
>   select id1 from teste where id1 = 1000000;
>
> EXPLAIN (analyze on, wal on, verbose on, format text)
>   select id2 from teste where id2 = 1000000;

This is not a bug.  You can't expect postgres to chose a good plan if you don't
have any statistics.  You should do an explicit "ANALYZE teste" after loading
your data (same for any bulk loading operation).





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-03-21 09:21 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 02:44 BUG #17443: Select command does not use brin index when enable_seqscan = on PG Bug reporting form <noreply@postgresql.org>
2022-03-21 09:21 ` Julien Rouhaud <rjuju123@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox