Dustin Sallings <dustin(at)spy(dot)net> writes:
> I was wondering, however, if there's a way I can use an index to
> avoid table scanning for this.
If you say "SET enable_seqscan TO off", and repeat the EXPLAIN, do you
get an indexscan plan?
I don't recommend doing such a SET for production purposes, but if this
works then the problem is just inaccurate selectivity/cost estimation.
I see that the on_pb operator has no selectivity estimator defined at
all :-( ... as a quick hack, try setting its oprrest and oprjoin to be
areasel and areajoinsel.
regards, tom lane