David Link <dlink(at)soundscan(dot)com> writes:
> The following large EXPLAIN SELECT Statement fails to return, but
> continues to take up processing time until it is killed.
> [ 52-way join... ]
Am I right in guessing that all the sales_xxx tables are the same size
and have similar statistics? I think the problem is that the planner is
faced with a large set of essentially equivalent plans and isn't pruning
the list aggressively enough. That's something we fixed in 8.0.
> Postgresql 7.4.8
You really oughta try something newer. On my machine, 7.4.12 plans a
52-way join in about a minute, and 8.0 and 8.1 in under a second.
I wonder also if there's not a better way to design the query...
maybe a UNION ALL would work better than nested joins.
regards, tom lane