On Fri, Nov 29, 2013 at 2:07 PM, Jan Michel <Jan(at)mueschelsoft(dot)de> wrote:
>
> When I run a second instance of this query in a unrelated database on the
> same server, they take 100% CPU, no iowait and they do not finish even
> after more than a day.
>
The planner is not aware of what else is going on in the server, so it
can't change plans with that in mind. So I think that that is a red
herring. I'd guess that the 2nd database is missing the geometry index, or
has it defined in some different way such that the database doesn't think
it can be used.
Are you sure that you get good plans when you run the exact same queries on
the exact same database/schema one at a time?
Cheers,
Jeff