On Thu, 31 Oct 2019 at 05:09, Tom Lane <t...@sss.pgh.pa.us> wrote: > David --- much of the complexity here comes from the addition of > the eclass_indexes infrastructure, so do you have any thoughts?
Hindsight makes me think I should have mentioned in the comment for eclass_indexes that it's only used for simple rels and remains NULL for anything else. All the code in equivclass.c either uses get_common_eclass_indexes() and get_eclass_indexes_for_relids() which go down to the simple rel level to obtain their eclass_indexes. When calling get_eclass_indexes_for_relids() we'll build a union Bitmapset with the indexes from each simple rel that the join rel is made from. We only ever directly use the eclass_indexes field when we're certain we're dealing with a simple rel already. get_eclass_indexes_for_relids() would do the same job, but using the field directly saves a bit of needless effort and memory allocations. So, in short, I don't really see why we need to set eclass_indexes for anything other than simple rels. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services