Tomas Vondra <> 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

                        regards, tom lane

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to