Re: pg9.6 segfault using simple query (related to use fk for join estimates) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg9.6 segfault using simple query (related to use fk for join estimates)
Date
Msg-id 26676.1465235091@sss.pgh.pa.us
Whole thread Raw
In response to Re: pg9.6 segfault using simple query (related to use fk for join estimates)  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> When it comes to improving multiple (multi-column) foreign keys, I think 
> it may get way more complicated that it might seem. What if the foreign 
> keys overlap, for example? Or what if the keys go in opposite directions 
> (cycle). And so on ...

I think you can group all FKs referencing the same table and discard
all their matched join clauses in favor of a single 1/N estimate
(and when I say "discard", that means you don't match those clauses
against later FKs, which should take care of the reciprocal-FK issue).
This is clearly correct if no nulls are involved.  We need to make some
estimate of how much to de-rate that figure for nulls, but I don't see
that it's any harder than what's already required for a single multicol
FK.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg9.6 segfault using simple query (related to use fk for join estimates)
Next
From: Robert Haas
Date:
Subject: Re: Changed SRF in targetlist handling