Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> My main problem is that selectivity is the wrong measurement. What
> users really want to be able to communicate is:
> 1. If you join tables a and b on x, the number of resulting rows will be
> the number of roows selected from b (since b.x id a foreign key
> referencing a.x).
FWIW, I believe the planner already gets that case right, because a.x
will be unique and it should know that. (Maybe not if the FK is across
a multi-column key, but in principle it should get it right.)
I agree though that meta-knowledge like this is important, and that
standard SQL frequently doesn't provide any adequate way to declare it.
regards, tom lane