Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong

From: Horimoto Yasuhiro <horimoto(at)clear-code(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong
Date: 2020-03-16 06:05:33
Message-ID: 20200316.150533.1702058889215288265.horimoto@clear-code.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I send a patch for this problem.

thanks!

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: BUG #16303: A condtion whether an index-only scan is possible includes a wrong
Date: Mon, 16 Mar 2020 06:02:25 +0000

> The following bug has been logged on the website:
>
> Bug reference: 16303
> Logged by: Horimoto Yasuhiro
> Email address: horimoto(at)clear-code(dot)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!
>

Attachment Content-Type Size
fix_check_index_only_scan.patch text/x-patch 2.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2020-03-16 06:35:53 Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong
Previous Message PG Bug reporting form 2020-03-16 06:02:25 BUG #16303: A condtion whether an index-only scan is possible includes a wrong