From: Tom Lane <tgl@sss.pgh.pa.us>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: New design for FK-based join selectivity estimation
Date: Mon, 13 Jun 2016 14:16:25 -0400
Message-ID: <29764.1465841785@sss.pgh.pa.us> (raw)
In-Reply-To: <CANP8+jLsiASHZ=5at_uw7wn7Ujkd6QVJeSf=w1qaoSOSKC3V4g@mail.gmail.com>
References: <31041.1465069446@sss.pgh.pa.us>
<CANP8+jLsiASHZ=5at_uw7wn7Ujkd6QVJeSf=w1qaoSOSKC3V4g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Simon Riggs <simon@2ndquadrant.com> writes:
> So a simple change is to make RelationGetFKeyList() only retrieve FKs with
> nKeys>1. Rename to RelationGetMultiColumnFKeyList(). That greatly reduces
> the scope for increased planning time.
FWIW, I don't particularly agree with that. It makes the relcache's fkey
storage extremely specific to this one use-case, a decision I expect we'd
regret later. And the planner needs to filter the fkey list anyway,
because it only wants fkeys that link to tables that are also in the
current query. Thus, my recommendation was that we should allow
RelationGetFKeyList to return a pointer directly to the cached info list
and require the planner to immediately copy (only) the entries that it
needs for the current query.
Another point here is that I'm now unconvinced that restricting the logic
to consider only multi-column fkeys is really what we want. It looks to
me like the code can also improve estimates in the case where there are
multiple single-column FKs linking to the same target relation. That
might not be too common for two-table queries, but I bet it happens a
lot in three-or-more-table queries.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, simon@2ndquadrant.com
Subject: Re: New design for FK-based join selectivity estimation
In-Reply-To: <29764.1465841785@sss.pgh.pa.us>
References: <31041.1465069446@sss.pgh.pa.us> <CANP8+jLsiASHZ=5at_uw7wn7Ujkd6QVJeSf=w1qaoSOSKC3V4g@mail.gmail.com> <29764.1465841785@sss.pgh.pa.us>
* 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