On Mon, 1 Feb 2021 at 18:57, Tom Lane <t...@sss.pgh.pa.us> wrote: > > I wrote: > > David Rowley <dgrowle...@gmail.com> writes: > >> Parent RT indexes are guaranteed to be lower than their children RT > >> indexes, > > > I was intentionally avoiding that assumption ;-). Maybe it buys enough > > to be worth the loss of generality, but ... > > Oh, it's too late at night. I now remember that the real problem > I had with that representation was that it cannot work for joinrels. > Currently we only apply this logic to partitioned baserels, but > don't you think it might someday be called on to optimize > partitionwise joins?
I've not looked in detail, but I think the code would need a pretty big overhaul before that could happen. For example, ever since we allowed ATTACH PARTITION to work without taking an AEL we now have a PartitionedRelPruneInfo.relid_map field that stores Oids for the executor to look at to see if it can figure out if a partition has been added since the plan was generated. Not sure how that can work with non-base rels as we have no Oid for join rels. Perhaps I'm just not thinking hard enough, but either way, it does seem like it would take a pretty big hit with a hammer to make it work. My current thinking is that being unable to represent join rels in a set of Relids is fairly insignificant compared to what would be required to get the feature to work correctly. David