Re: Odd planner choice? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Odd planner choice?
Date
Msg-id 15493.1097265882@sss.pgh.pa.us
Whole thread Raw
In response to Odd planner choice?  ("Gary Doades" <gpd@gpdnet.co.uk>)
Responses Re: Odd planner choice?  ("Gary Doades" <gpd@gpdnet.co.uk>)
List pgsql-performance
"Gary Doades" <gpd@gpdnet.co.uk> writes:
> If I remove the redundant clauses, the planner now estimates 1000 rows returned from
> the table, not unreasonable since it has no statistics. But *why* in that case, with *more*
> estimated rows does it choose to materialize that table (26 rows) 573416 times!!!

It isn't.  It's materializing that once and scanning it 573416 times,
once for each row in the outer relation.  And this is not a bad plan
given the estimates.  If it had stuck to what you call the good plan,
and there *had* been 1000 rows in the temp table, that plan would have
run 1000 times longer than it did.

As a general rule, if your complaint is that you get a bad plan for an
unanalyzed table, the response is going to be "so analyze the table".

            regards, tom lane

pgsql-performance by date:

Previous
From: "Gary Doades"
Date:
Subject: Re: Odd planner choice?
Next
From: "Gary Doades"
Date:
Subject: Re: Odd planner choice?