I wrote:
> Ah. So this must be something to do with the foreign-key-driven rowcount
> estimates we added in 9.6. Will look into it, thanks for the report!
I think the answer is that we failed to consider inheritance cases at all
while developing the aforementioned logic. For the moment, I've
band-aided this by disabling the FK estimation logic when either relation
is an inheritance parent. If you need a patch immediately, see
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=23c6c437f98c996092c0adfad6152d9cc699c8b0
regards, tom lane