"Tom Lane" <tgl@sss.pgh.pa.us> writes:
> This rule works for all the locales I have installed ... but I don't
> have any Far Eastern locales installed. Also, my test cases are only
> covering ASCII characters, and I believe many locales have some non-ASCII
> letters that sort after 'Z'. I'm not sure how hard we need to try to
> cover those corner cases, though. It is ultimately only an estimate...
If I understand correctly what we're talking about it's generating estimates
for LIKE 'foo%' using the algorithm which makes sense for C locale which means
generating the next range of values which start with 'foo%'.
It seems to me the problematic situations is when the most-frequent-values
come into play. Being off slightly in the histogram isn't going to generate
very inaccurate estimates but including or not a most-frequent-value could
throw off the estimate severely.
Could we not use the bogus range to calculate the histogram estimate but apply
the LIKE pattern directly to the most-frequent-values instead of applying the
bogus range? Or would that be too much code re-organization for now?
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!