pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Postpone calculating total_table_pages until after pruning/exclu
Date: Wed, 07 Nov 2018 17:13:03 +0000
Message-ID: <E1gKRO3-0000Zf-OD@gemulon.postgresql.org> (raw)

Postpone calculating total_table_pages until after pruning/exclusion.

The planner doesn't make any use of root->total_table_pages until it
estimates costs of indexscans, so we don't need to compute it as
early as that's currently done.  By doing the calculation between
set_base_rel_sizes and set_base_rel_pathlists, we can omit relations
that get removed from the query by partition pruning or constraint
exclusion, which seems like a more accurate basis for costing.

(Historical note: I think at the time this code was written, there
was not a separation between the "set sizes" and "set pathlists"
steps, so that this approach would have been impossible at the time.
But now that we have that separation, this is clearly the better way
to do things.)

David Rowley, reviewed by Edmund Horner

Discussion: https://postgr.es/m/CAKJS1f-NG1mRM0VOtkAG7=ZLQWihoqees9R4ki3CKBB0-fRfCA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c6e4133fae1fde93769197379ffcc2b379845113

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 45 +++++++++++++++++++++++++++++++++--
src/backend/optimizer/plan/planmain.c | 30 -----------------------
src/backend/optimizer/util/plancat.c  |  5 ++--
src/include/nodes/relation.h          |  8 +++----
4 files changed, 49 insertions(+), 39 deletions(-)



Message-ID: <E1gKRO3-0000Zf-OD@gemulon.postgresql.org>
Permalink:  ../E1gKRO3-0000Zf-OD@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gKRO3-0000Zf-OD@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Postpone calculating total_table_pages until after pruning/exclu
  In-Reply-To: <E1gKRO3-0000Zf-OD@gemulon.postgresql.org>
  References: <E1gKRO3-0000Zf-OD@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox