I wrote:
> I'm not sure what I think about this proposal. I agree it looks dumb
> to estimate the selectivity of "é" differently from "e", and even more
> so for it to depend on the encoding. However, I believe this per-byte
> counting was intentional, with an eye to Far Eastern character sets.
> A single ideogram of Chinese or Japanese probably carries about the
> same selectivity as a word of English, so giving it the same
> selectivity as "e" likewise doesn't sound great. I'm not trying to
> claim that per-byte counting is ideal, but there is more here than
> meets the eye, so I'm loath to change a longstanding behavior on
> the basis of no discussion or evidence. How can we arrive at a
> behavior that is sensible for both of those cases?
After noodling about that for awhile, I have a potential answer.
Basically we need (I think) to distinguish letter-y characters
from ideogram-y characters. But there is a serviceable, and
fast, approximation to that in our infrastructure already:
check pg_encoding_dsplen() and see if it's 1 or 2. Double-width
characters can be counted on to carry more information than
regular-width ones. I don't have an immediate proposal about
what selectivity multiplier to assign to double-width characters,
but this approach seems like there's potential to accomplish
what the original hack hoped for without the encoding dependency.
regards, tom lane