Reinhard Vicinus <rvicinus@xxxxxx> writes: > PostgreSQL version: 8.1.6 > The following query needs a lot of time because the query planner > reorders the joins: Try reducing random_page_cost, increasing effective_cache_size, and/or updating to PG 8.2. Any of these are likely to make it like the nestloop plan better... regards, tom lane