Re: estimates for nested loop very wrong? - Mailing list pgsql-sql

From Tom Lane
Subject Re: estimates for nested loop very wrong?
Date
Msg-id 6396.1050006228@sss.pgh.pa.us
Whole thread Raw
In response to Re: estimates for nested loop very wrong?  (joostje@komputilo.org)
List pgsql-sql
joostje@komputilo.org writes:
> Je 2003/04/10(4)/12:04, Tom Lane skribis:
>> Please try increasing the statistics target (see ALTER TABLE) for db.id, then
>> re-analyze and see if the estimates get better.  The default setting is
>> 10 --- try 20, 50, 100 to see what happens.

> Well, the n_distinct estimates get better, but the cost estimates still
> don't quite add up: `actual cost' is 23.24, cost estimate never gets
> below 49930.

How much RAM do you have on this machine?  If the system is caching
a goodly fraction of the tables, it'd be appropriate to lower
random_page_cost (or increase effective_cache_size).

I do recall a thread awhile back to the effect that the planner
overestimates the cost of nestloop/indexscan plans because it doesn't
account for the fact that successive indexscans aren't independent ---
the top levels of the index btree, at least, are certain to remain
in cache from loop to loop.  That seems unlikely to account for as
large an estimation error as you're showing here, though.  Is there
anything nonrandom about your data statistics?  (For example, could
it be that all the db rows matching a particular tmp0 row are physically
bunched together?)
        regards, tom lane



pgsql-sql by date:

Previous
From: joostje@komputilo.org
Date:
Subject: Re: estimates for nested loop very wrong?
Next
From: Tom Lane
Date:
Subject: Re: estimates for nested loop very wrong?