Oleg Lebedev <olebedev@waterford.org> writes:
> select attname, attdispersion, s.*
> from pg_statistic s, pg_attribute a, pg_class c
> where starelid = c.oid and attrelid=c.oid and staattnum=attnum and relname='activity';
> attname | attdispersion | starelid | staattnum | staop | stanullfrac | stacommonfrac |
stacommonval | staloval | stahival
>
-------------------------+---------------+----------+-----------+-------+-------------+---------------+--------------------------------------+-------------+------------------------------
> productcode | 0.002625 | 14559105 | 17 | 1066 | 0 | 0.0125 | m3nt22
| 0000 | t3nt15
Well, I can see that 7.1 wouldn't be likely to make a good estimate
about the selectivity of productcode ~ '^m3' on this table; it doesn't
take stacommonval into account (and that's only 1% of the table anyway),
and the range '0000' .. 't3nt15' is too wide to make it plausible that
m3's take up 98% of the table. I believe 7.2 will do better though.
Care to try out your database with a beta version?
regards, tom lane