2008/11/7 David Wilson <david.t.wilson@xxxxxxxxx>
On Fri, Nov 7, 2008 at 4:14 AM, Віталій Тимчишин <tivv00@xxxxxxxxx> wrote:Have you tried increasing the default_statistics_target? The planner
> "Merge Join (cost=518771.07..62884559.80 rows=1386158171 width=32) (actual
> time=30292.802..755751.242 rows=34749 loops=1)"
is expecting 1.3 billion rows to be produced from a query that's only
actually producting 35k, which probably indicates some very bad
statistics.
The planner seems to think that every second pair from company<->company join will succeed with this join _expression_ (1386158171 ~ 52648^2 / 2). That is not true.
Anyway, I've tried to set default_statistics_target to 1000, then analyze. Nothing've changed
Anyway, I've tried to set default_statistics_target to 1000, then analyze. Nothing've changed
At the same time, the materialize step produces 242
million rows when the planner only expects to produce 2.3, indicating
a similar problem in the opposite direction. This probably means that
the planner is choosing plans that would be optimal if it was making
good guesses but are decidedly sub-optimal for your actual data.
That is even more strange, because materialize step must produce exactly the rows it takes from sort, that is 2316503, so I don't get how table scan + sort + materialize can multiply number of rows by 100.