David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
> It seems quite strange to me that we calculate total_pages before any
> partition pruning and constraint exclusion is performed during
> set_base_rel_sizes(). Wouldn't it be better to wait until after that's
> done so we don't mistakenly count relations we're not going to scan?
> Delaying the calculation until after set_base_rel_sizes() means it's
> still done in time before it's needed in set_base_rel_pathlists().
I think that when this was first done, there was not a separation between
those passes over the rangetable, so that such a simple fix would have
been impossible.
> The attached patch implements the change.
Please add to next CF. It's a bit late to be doing such things in v11,
IMO.
regards, tom lane