pgsql-performance(at)ian(dot)org writes:
> One query works fast, returning results in under a second. If I insert
> one more join into the table however, it switches to nested-loops and
> takes minutes.
I think you need to raise from_collapse_limit and/or
join_collapse_limit.
regards, tom lane