aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/indxpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-11-07 22:37:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-11-07 22:37:33 +0000
commit5b860028f1e684ebbf5363eceeaf618be7cd42e6 (patch)
tree37f52005618cab44cdfcc34baf889f9e277819dc /src/backend/optimizer/path/indxpath.c
parent69946e80adc2b006980af3f4167fc9f35676cbb1 (diff)
downloadpostgresql-5b860028f1e684ebbf5363eceeaf618be7cd42e6.tar.gz
postgresql-5b860028f1e684ebbf5363eceeaf618be7cd42e6.zip
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...
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r--src/backend/optimizer/path/indxpath.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index f35372ebbef..35c57434830 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.212.2.3 2007/07/31 19:53:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.212.2.4 2007/11/07 22:37:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2801,6 +2801,7 @@ prefix_quals(Node *leftop, Oid opclass,
Oid datatype;
Oid oproid;
Expr *expr;
+ FmgrInfo ltproc;
Const *greaterstr;
Assert(pstatus != Pattern_Prefix_None);
@@ -2897,13 +2898,14 @@ prefix_quals(Node *leftop, Oid opclass,
* "x < greaterstr".
*-------
*/
- greaterstr = make_greater_string(prefix_const);
+ oproid = get_opclass_member(opclass, InvalidOid,
+ BTLessStrategyNumber);
+ if (oproid == InvalidOid)
+ elog(ERROR, "no < operator for opclass %u", opclass);
+ fmgr_info(get_opcode(oproid), &ltproc);
+ greaterstr = make_greater_string(prefix_const, &ltproc);
if (greaterstr)
{
- oproid = get_opclass_member(opclass, InvalidOid,
- BTLessStrategyNumber);
- if (oproid == InvalidOid)
- elog(ERROR, "no < operator for opclass %u", opclass);
expr = make_opclause(oproid, BOOLOID, false,
(Expr *) leftop, (Expr *) greaterstr);
result = lappend(result,