1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-24 10:47:04 +03:00

Clarify use of btree indexes for ILIKE and ~*.

This commit is contained in:
Bruce Momjian 2006-01-18 22:26:01 +00:00
parent 0bfd90ff32
commit 2e2c4f424f

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.54 2005/11/04 23:14:00 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.54.2.1 2006/01/18 22:26:01 momjian Exp $ -->
<chapter id="indexes"> <chapter id="indexes">
<title id="indexes-title">Indexes</title> <title id="indexes-title">Indexes</title>
@ -141,17 +141,21 @@ CREATE INDEX test1_id_index ON test1 (id);
<para> <para>
The optimizer can also use a B-tree index for queries involving the The optimizer can also use a B-tree index for queries involving the
pattern matching operators <literal>LIKE</>, pattern matching operators <literal>LIKE</> and <literal>~</literal>
<literal>ILIKE</literal>, <literal>~</literal>, and <emphasis>if</emphasis> the pattern is a constant and is anchored to
<literal>~*</literal>, <emphasis>if</emphasis> the pattern is a constant the beginning of the string &mdash; for example, <literal>col LIKE
and is anchored to the beginning of the string &mdash; for example, 'foo%'</literal> or <literal>col ~ '^foo'</literal>, but not
<literal>col LIKE 'foo%'</literal> or <literal>col ~ '^foo'</literal>, <literal>col LIKE '%bar'</literal>. However, if your server does not
but not <literal>col LIKE '%bar'</literal>. However, if your server does use the C locale you will need to create the index with a special
not use the C locale you will need to create the index with a operator class to support indexing of pattern-matching queries. See
special operator class to support indexing of pattern-matching queries. <xref linkend="indexes-opclass"> below. It is also possible to use
See <xref linkend="indexes-opclass"> below. B-tree indexes for <literal>ILIKE</literal> and
<literal>~*</literal>, but only if the pattern starts with
non-alphabetic characters, i.e. characters that are not affected by
upper/lower case conversion.
</para> </para>
<para> <para>
<indexterm> <indexterm>
<primary>index</primary> <primary>index</primary>