On 09/30/2015 12:55 PM, Tomas Vondra wrote:
> Hello!
>
> On 09/30/2015 10:29 AM, Kyotaro HORIGUCHI wrote:
>
>> By the way your comment for indexrinfos is as following,
>>
>>> * 'indexrinfos' is a list of RestrictInfo nodes from the query's WHERE
>>> * or JOIN conditions, excluding those implied by the index predicate
>>> * (if the index is not partial, the list includes all restriction
>>> clauses).
>>
>> But the v4 patch instead leaves it empty for non-partial
>> indexes:) I prefer to follow this comment because looking the
>> condition (index->indpred != NIL) for such purpose in
>> build_index_paths is somewhat uneasy for me. But I don't insist
>> on that if you choose to avoid useless memory and clock
>> consumption to construct a list which is not so meaningful for
>> non-partial indexes (it is almost all cases).
>
> Good point. I think we may simply point indexrinfos to the existing list
> of restrictions in that case - we don't need to copy it. So no
> additional memory / CPU consumption, and it should make the code working
> with it a bit simpler.
Attached is v5 of the patch improving the comments (rephrasing, moving
before function etc.).
I also attempted to fix the issue with empty list for non-partial
indexes by simply setting it to rel->baserestrictinfo in
match_restriction_clauses_to_index (for non-partial indexes), but that
results in a bunch of
ERROR: variable not found in subplan target list
during "make installcheck". I can't quite wrap my head around why.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services