Re: 7.4.7: strange planner decision - Mailing list pgsql-general

From Tom Lane
Subject Re: 7.4.7: strange planner decision
Date
Msg-id 27805.1121264120@sss.pgh.pa.us
Whole thread Raw
In response to Re: 7.4.7: strange planner decision  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Richard Huxton <dev@archonet.com> writes:
> What happens to the plan if you SET enable_seqscan=false; first? It's
> presumably getting the row-estimate right, so unless there's terrible
> correlation on "base" in the files table I can only assume it's getting
> the cost estimates horribly wrong.

I think you'll find that the results suck ;-).  It looks to me that the
planner is making exactly the right choice here.  The only plausible
alternative is a nestloop with inner indexscan on "files", which would
imply 176160 separate index probes into "files", which is unlikely to
win compared to one seqscan.  (In the aggregate the index probes are
likely to end up touching every page of "files" anyway --- you would
need a much larger files table before this stopped being true.)

If you want to compare the nestloop plan to test this theory, turning
off enable_hashjoin and (if necessary) enable_mergejoin would be the
better way to get it.  But let's see EXPLAIN ANALYZE results for both
cases, not just EXPLAIN.

            regards, tom lane

pgsql-general by date:

Previous
From: Roman Neuhauser
Date:
Subject: Re: 7.4.7: strange planner decision
Next
From: Einar Indridason
Date:
Subject: Re: Strange memory behaviour with PGreset() ...