diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-27 00:13:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-27 00:13:09 +0000 |
commit | 7b8a63c3e922b8730e98a20a2c30c5460ddf2306 (patch) | |
tree | a66a78e79e9e8efb89622f5206461e469b54fd3c /src/backend/optimizer/path/indxpath.c | |
parent | a3d9a2421ad3c16c22c82734a1d12be472bf9ba5 (diff) | |
download | postgresql-7b8a63c3e922b8730e98a20a2c30c5460ddf2306.tar.gz |
Alter the xxx_pattern_ops opclasses to use the regular equality operator of
the associated datatype as their equality member. This means that these
opclasses can now support plain equality comparisons along with LIKE tests,
thus avoiding the need for an extra index in some applications. This
optimization was not possible when the pattern opclasses were first introduced,
because we didn't insist that text equality meant bitwise equality; but we
do now, so there is no semantic difference between regular and pattern
equality operators.
I removed the name_pattern_ops opclass altogether, since it's really useless:
name's regular comparisons are just strcmp() and are unlikely to become
something different. Instead teach indxpath.c that btree name_ops can be
used for LIKE whether or not the locale is C. This might lead to a useful
speedup in LIKE queries on the system catalogs in non-C locales.
The ~=~ and ~<>~ operators are gone altogether. (It would have been nice to
keep them for backward compatibility's sake, but since the pg_amop structure
doesn't allow multiple equality operators per opclass, there's no way.)
A not-immediately-obvious incompatibility is that the sort order within
bpchar_pattern_ops indexes changes --- it had been identical to plain
strcmp, but is now trailing-blank-insensitive. This will impact
in-place upgrades, if those ever happen.
Per discussions a couple months ago.
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 4fc7c53654..e0bd548008 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.230 2008/05/16 16:31:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.231 2008/05/27 00:13:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2178,9 +2178,8 @@ match_special_index_operator(Expr *clause, Oid opfamily, case OID_NAME_ICLIKE_OP: case OID_NAME_REGEXEQ_OP: case OID_NAME_ICREGEXEQ_OP: - isIndexable = - (opfamily == NAME_PATTERN_BTREE_FAM_OID) || - (opfamily == NAME_BTREE_FAM_OID && lc_collate_is_c()); + /* name uses locale-insensitive sorting */ + isIndexable = (opfamily == NAME_BTREE_FAM_OID); break; case OID_BYTEA_LIKE_OP: @@ -2700,7 +2699,6 @@ prefix_quals(Node *leftop, Oid opfamily, break; case NAME_BTREE_FAM_OID: - case NAME_PATTERN_BTREE_FAM_OID: datatype = NAMEOID; break; |