• Robert Haas's avatar
    Expand partitioned table RTEs level by level, without flattening. · 0a480502
    Robert Haas authored
    Flattening the partitioning hierarchy at this stage makes various
    desirable optimizations difficult.  The original use case for this
    patch was partition-wise join, which wants to match up the partitions
    in one partitioning hierarchy with those in another such hierarchy.
    However, it now seems that it will also be useful in making partition
    pruning work using the PartitionDesc rather than constraint exclusion,
    because with a flattened expansion, we have no easy way to figure out
    which PartitionDescs apply to which leaf tables in a multi-level
    partition hierarchy.
    
    As it turns out, we end up creating both rte->inh and !rte->inh RTEs
    for each intermediate partitioned table, just as we previously did for
    the root table.  This seems unnecessary since the partitioned tables
    have no storage and are not scanned.  We might want to go back and
    rejigger things so that no partitioned tables (including the parent)
    need !rte->inh RTEs, but that seems to require some adjustments not
    related to the core purpose of this patch.
    
    Ashutosh Bapat, reviewed by me and by Amit Langote.  Some final
    adjustments by me.
    
    Discussion: http://postgr.es/m/CAFjFpRd=1venqLL7oGU=C1dEkuvk2DJgvF+7uKbnPHaum1mvHQ@mail.gmail.com
    0a480502
planner.c 192 KB