Csaba Nagy <nagy(at)ecircle-ag(dot)com> writes:
> db=# analyze verbose temp_table_a;
> INFO: analyzing "public.temp_table_a"
> INFO: "temp_table_a": scanned 3000 of 655299 pages, containing 1887000 live rows and 0 dead rows; 3000 rows in sample, 412183071 estimated total rows
Hmm. So the bottom line here is probably that that's not a big enough
sample to derive a realistic n_distinct value. Or maybe it is ... how
many values of "a" are there really, and what's the true distribution of
counts? Do the plan estimates get closer to reality if you set a higher
statistics target?
regards, tom lane