From: | Horimoto Yasuhiro <horimoto(at)clear-code(dot)com> |
---|---|
To: | david(dot)g(dot)johnston(at)gmail(dot)com |
Cc: | 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 08:22:30 |
Message-ID: | 20200316.172230.2295109568745072390.horimoto@clear-code.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hello,
Thank you for your comments.
I should have explained much more about this case. Sorry.
In this case, gistcanreturn() returns false:
https://github.com/postgres/postgres/blob/master/src/backend/access/gist/gistget.c#L798-L799
Because tsvector_ops provides GIST_COMPRESS_PROC:
https://github.com/postgres/postgres/blob/master/src/include/access/gist.h#L31
https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_amproc.dat#L530-L532
and doesn't provide GIST_FETCH_PROC:and provides GIST_COMPRESS_PROC:
https://github.com/postgres/postgres/blob/master/src/include/access/gist.h#L37
https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_amproc.dat#L524-L543
Reurning false from amcanreturn() function such as gistcanreturn() means the index can't support
index-only scans on the given column:
https://www.postgresql.org/docs/12/index-functions.html
bool
amcanreturn (Relation indexRelation, int attno);
Check whether the index can support index-only scans on the given column, by returning the
indexed column values for an index entry in the form of an IndexTuple.
So I think that choosing index-only scan for this case (false is returned by gistcanreturn() case)
isn't expected behavior.
Background:
We're developing a PostgreSQL index, PGroonga: https://pgroonga.github.io/
It supports index-only scans for most supported types but doesn't support
index-only scan for jsonb type. Because we can't reconstruct the original data
from data in indexed data.
We found the problem I reported with PGroonga:
https://github.com/pgroonga/pgroonga/issues/101
This problem causes an error because PGroonga can't return
IndexScanDesc::xs_itup but IndexScanDesc::xs_want_itup is true.
Because PostgreSQL requests index-only scan even when PGroonga
returns false by amcanreturn().
We've introduced the following workaround:
https://github.com/pgroonga/pgroonga/commit/0390f79f810c44422940c4ef701c186055b4899e
It returns a NULL tuple instead of real tuple data.
IMO, it's better that PostgreSQL doesn't choose index-only scan in this case.
Or index developers need to implement workaround in each index.
thanks!
From: "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Subject: Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong
Date: Sun, 15 Mar 2020 23:35:53 -0700
> On Sunday, March 15, 2020, Horimoto Yasuhiro <horimoto(at)clear-code(dot)com>
> wrote:
>
>> I send a patch for this problem.!
>>
>> 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
>>
>> > 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.
>>
>>
>
>> > In my opinion, we expected that the query planner doesn't choose an
>> > index-only scan in the above case.
>> >
>>
>>
> I don't see a behavioral bug here. I would expect that any index would be
> an acceptable match for a query whose set of return columns is the empty
> set. The empty set is a subset of all sets.
>
> David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-03-16 15:20:43 | Re: BUG #16303: A condtion whether an index-only scan is possible includes a wrong |
Previous 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 |