pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: horimoto@clear-code.com
Subject: BUG #16303: A condtion whether an index-only scan is possible includes a wrong
Date: Mon, 16 Mar 2020 06:02:25 +0000
Message-ID: <16303-889581eb40fc0691@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16303
Logged by:          Horimoto Yasuhiro
Email address:      horimoto@clear-code.com
PostgreSQL version: 12.2
Operating system:   Debian 10.3
Description:        

Hello, developers.

I think that the condition of whether an index-only scan is possible
includes a wrong.

For example, in the following case, the index has no data to return. Because
the query doesn't use specify columns.
However, the query planner choice index-only scan.

create table gist_count_tbl (tsv tsvector);
insert into gist_count_tbl values (null);
create index gist_count_tbl_index on gist_count_tbl using gist (tsv);

vacuum analyze gist_count_tbl;

set enable_seqscan=off;
set enable_bitmapscan=off;
set enable_indexonlyscan=on;

explain (costs off)
select count(*) from gist_count_tbl;
                             QUERY PLAN                             
--------------------------------------------------------------------
 Aggregate
   ->  Index Only Scan using gist_count_tbl_index on gist_count_tbl
(2 rows)

In my opinion, we expected that the query planner doesn't choose an
index-only scan in the above case. 

In fact, index_canreturn_attrs of
https://github.com/postgres/postgres/blob/master/src/backend/optimizer/path/indxpath.c#L1951
is NULL in the above case.

thanks!



view thread (6+ messages)  latest in thread

Message-ID: <16303-889581eb40fc0691@postgresql.org>
Permalink:  ../16303-889581eb40fc0691@postgresql.org/
Also on:    postgresql.org/message-id/16303-889581eb40fc0691@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, horimoto@clear-code.com
  Subject: Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong
  In-Reply-To: <16303-889581eb40fc0691@postgresql.org>
  References: <16303-889581eb40fc0691@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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