Re: New design for FK-based join selectivity estimation - Mailing list pgsql-hackers

From Tom Lane
Subject Re: New design for FK-based join selectivity estimation
Date
Msg-id 25869.1467228865@sss.pgh.pa.us
Whole thread Raw
In response to Re: New design for FK-based join selectivity estimation  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-hackers
Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> If the query was produced by rule expansion then the code that populates
> fkinfo includes FK references to the OLD and NEW RTEs, but those might not
> appear in the jointree (the testcase for the bug is a DELETE rule where
> NEW clearly doesn't apply) and hence build_simple_rel was not called
> (causing find_base_rel to fail). Not sure what the right fix is.

Meh.  I had a vaguely uneasy feeling that just scanning the rtable was
too simplistic, but hadn't thought hard about it.

For a really correct fix we could search the jointree to see which rels
are in it, but that would add code and cycles.  A slightly cheating way to
do it is to not use find_base_rel() but look into the simple_rel_array for
ourselves, and do nothing if there's no rel corresponding to the RTE
index.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: New design for FK-based join selectivity estimation
Next
From: Alvaro Herrera
Date:
Subject: Re: WIP: About CMake v2