gdh@eyjar.is writes:
> Any ideas what I can do to make the query running in < 10 seconds?
Increase work_mem (or sort_mem in older releases). PG is dropping
back from the hash plan because it thinks the hashtable won't fit
in work_mem.
regards, tom lane