"Gregory Wood" <gregw@com-stock.com> writes:
> Trying to use a single column index on a somewhat large table (1.9M rows),
> and PostgreSQL really doesn't want to. It estimates the number of rows at
> 12749 (actual 354), which is only .6% of the table... well within reasonable
> index range I would think. And yes, I've run an analyze on the table.
Could we see the analyze results --- ie, the pg_stats row for the
idx_siteid column?
Increasing the statistics target for that column might help, but I'm
interested to see what it thinks the distribution is right now. The
problem AFAICT is the factor-of-36 overestimation of the number of
matching rows; had that estimate been even within a factor of 20 of
correct, the correct plan would have been chosen.
regards, tom lane