joostje(at)komputilo(dot)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