Should total_pages be calculated after partition pruning and constraint exclusion?

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Should total_pages be calculated after partition pruning and constraint exclusion?
Date: 2018-05-15 19:46:01
Message-ID: CAKJS1f_eUz0_h5_vU1rqE7wuxMcoENcWK2FTODz0pOyxp3_Uig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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().

The attached patch implements the change.

There are no visible plan changes in the regression tests, but the
change can affect the plans for larger partitioned tables.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
total_pages_after_pruning.patch application/octet-stream 3.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2018-05-15 19:55:46 Re: Postgres 11 release notes
Previous Message legrand legrand 2018-05-15 19:45:54 Re: explain (verbose off, normalized) vs query planid