diff options
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/pgtrgm.sgml | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/src/sgml/pgtrgm.sgml b/doc/src/sgml/pgtrgm.sgml index 27a23067205..9210899ec24 100644 --- a/doc/src/sgml/pgtrgm.sgml +++ b/doc/src/sgml/pgtrgm.sgml @@ -137,8 +137,10 @@ The <filename>pg_trgm</filename> module provides GiST and GIN index operator classes that allow you to create an index over a text column for the purpose of very fast similarity searches. These index types support - the above-described similarity operators (and no other operators, so you may - want a regular B-tree index too). + the above-described similarity operators, and additionally support + trigram-based index searches for <literal>LIKE</> and <literal>ILIKE</> + queries. (These indexes do not support equality nor simple comparison + operators, so you may need a regular B-tree index too.) </para> <para> @@ -182,6 +184,18 @@ SELECT t, t <-> '<replaceable>word</>' AS dist </para> <para> + Beginning in <productname>PostgreSQL</> 9.1, these index types also support + index searches for <literal>LIKE</> and <literal>ILIKE</>, for example +<programlisting> +SELECT * FROM test_trgm WHERE t LIKE '%foo%bar'; +</programlisting> + The index search works by extracting trigrams from the search string + and then looking these up in the index. The more trigrams in the search + string, the more effective the index search is. Unlike B-tree based + searches, the search string need not be left-anchored. + </para> + + <para> The choice between GiST and GIN indexing depends on the relative performance characteristics of GiST and GIN, which are discussed elsewhere. As a rule of thumb, a GIN index is faster to search than a GiST index, but |