Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> What could I do to make it easier to choose a better plan?
Increase sort_mem. You want it to pick a "hashed subplan", but
it's not doing so because 64000 rows won't fit in the default
sort_mem.
regards, tom lane