"Vyacheslav Kalinin" <vka@xxxxxxxx> writes: > Here is the reproduce code: After tracing through this I see that the problem is that we don't have statistics for inheritance trees, and so you're getting a default estimate for the selectivity of the join condition. I'm not sure why the similar example I tried last night didn't show a bogus-looking rowcount estimate, but in any case the lack of stats is the real issue. This should get fixed sometime, but don't hold your breath ... regards, tom lane