Improve the performance of LIKE/regex estimation in non-C locales, by making
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 7 Nov 2007 22:37:43 +0000 (22:37 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 7 Nov 2007 22:37:43 +0000 (22:37 +0000)
commitb7e870c768df8dc8c01c1ba1ffffc82512bd42e1
tree557f92977b9c0db4ff55a1b3e724829e08282290
parent89eee257cf7dd3effb7ec5a7ac035d09af680a9a
Improve the performance of LIKE/regex estimation in non-C locales, by making
make_greater_string() try harder to generate a string that's actually greater
than its input string.  Before we just assumed that making a string that was
memcmp-greater was enough, but it is easy to generate examples where this is
not so when the locale is not C.  Instead, loop until the relevant comparison
function agrees that the generated string is greater than the input.

Unfortunately this is probably not enough to guarantee that the generated
string is greater than all extensions of the input, so we cannot relax the
restriction to C locale for the LIKE/regex index optimization.  But it should
at least improve the odds of getting a useful selectivity estimate in
prefix_selectivity().  Per example from Guillaume Smet.

Backpatch to 8.1, mainly because that's what the complainant is using...
src/backend/optimizer/path/indxpath.c
src/backend/utils/adt/selfuncs.c
src/include/utils/selfuncs.h