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 4867.1049993075@sss.pgh.pa.us
Whole thread Raw
In response to Re: estimates for nested loop very wrong?  (joostje@komputilo.org)
Responses Re: estimates for nested loop very wrong?  (joostje@komputilo.org)
List pgsql-sql
joostje@komputilo.org writes:
> Unless I'm mistaken, pg_nstats.n_distinct should be (aproximately) the same as
> count(distinct(id)), but it obviously isn't. Also the most_common_freqs
> values are about a 100 times higher than in reality, and, even tough about
> 900 values of id occur more often than 40 times, in the 'most_common_vals'
> list are 7 (of the 10) vals that occur less than 40 times, and the real
> top two isn't even represented.

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.
        regards, tom lane



pgsql-sql by date:

Previous
From: joostje@komputilo.org
Date:
Subject: Re: estimates for nested loop very wrong?
Next
From: Ian Barwick
Date:
Subject: Re: INSERT INTO ... SELECT (PostgreSQL vs. MySQL)