Re: Performance issue in foreign-key-aware join estimation - Mailing list pgsql-hackers

From David Rowley
Subject Re: Performance issue in foreign-key-aware join estimation
Date
Msg-id CAKJS1f9RDF9R+kUygh1TawCGx3uWUBtaMo75oNvDN64MHUVmSA@mail.gmail.com
Whole thread Raw
In response to Re: Performance issue in foreign-key-aware join estimation  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
On Wed, 26 Dec 2018 at 09:50, Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote:
> Yeah, good questions. I think the simplest thing we could do is building
> them on the first access - that would at least ensure we don't build the
> index without accessing it at least once.

I think we first need to focus on what is back-patchable here.  The
problem I see with the equivalence class index idea is that it would
require passing the index down into
match_eclasses_to_foreign_key_col() which is not a static function, so
we can't really go changing its signature on a backbranch.

Another idea would be to create a new version of
match_eclasses_to_foreign_key_col() which uses the index, which would
mean we'd not break any extensions that might happen to use
match_eclasses_to_foreign_key_col().

Ideally, the quick fix in the v1 patch would be good enough for the
backbranches, but a quick bit of benchmarking shows that there's still
a big regression to what the performance is like without the foreign
keys.

(Average of EXPLAIN over 60 seconds)

foreign key qual matching code commented out: 2486.204 ms
Master: 13909.551 ms
v1 patch: 7310.719 ms

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


pgsql-hackers by date:

Previous
From: James Coleman
Date:
Subject: Using Btree to Provide Sorting on Suffix Keys with LIMIT
Next
From: Noah Misch
Date:
Subject: Re: Augment every test postgresql.conf