@@ -505,15 +505,16 @@ SELECT * FROM logs WHERE msg @~ 'connection (refused|timed out)';
505505```
506506
507507` @~ ` and ` re2match(text, text) ` match identically, produce the same row
508- estimates, and both use the b-tree ranges below. Only ` @~ ` can use a GIN
509- index, since Postgres ties GIN operator classes to operators, not functions.
508+ estimates, and both use the b-tree ranges [ described
509+ below] ( #b-tree-range-from-an-anchored-prefix ) . Only ` @~ ` can use a GIN index,
510+ since Postgres ties GIN operator classes to operators, not functions.
510511
511512## Index Support
512513
513514Without an index, every RE2 filter reads whole table. Two mechanisms below let
514515applicable patterns visit only rows that could match, then recheck the exact
515- match on each candidate: results never change, only how fast they arrive, with
516- one known GIN exception noted below.
516+ match on each candidate: results never change, only how quickly they arrive,
517+ with one known GIN exception noted below.
517518
518519Matching, indexed or not, compares raw UTF-8 bytes without Unicode
519520normalization: a pattern with a composed character (` é ` as one code point)
@@ -522,11 +523,11 @@ accent). Pattern and haystack must agree on normalization form.
522523
523524### B-tree range from an anchored prefix
524525
525- When pattern is a constant starting with ` ^ ` and a fixed prefix, ` re2match ` and
526- ` @~ ` filters read only the index range covering that prefix. No query or index
527- change needed , provided the index orders bytewise: a ` text_pattern_ops ` index,
528- or a default b-tree whose collation sorts like ` C ` ( ` C ` , ` POSIX ` , builtin ` C `
529- and ` C.UTF8 ` ).
526+ For a constant pattern starting with ` ^ ` and a fixed prefix, ` re2match ` and
527+ ` @~ ` read only the index range covering that prefix. This feature requires no
528+ query or index change , provided the index orders bytewise, such as a
529+ ` text_pattern_ops ` index or a default b-tree whose collation sorts like ` C `
530+ ( ` C ` , ` POSIX ` , builtin ` C ` and ` C.UTF8 ` ).
530531
531532``` sql
532533CREATE INDEX ON logs (msg text_pattern_ops);
@@ -544,8 +545,9 @@ to the plan the query would otherwise get.
544545` gin_re2_ops ` indexes three-character sequences (trigrams) of each value.
545546A ` @~ ` query reduces its pattern to literal text every match needs.
546547
547- Below example finds ` connection ` plus ` refused ` or ` timed out ` and visits
548- only rows containing necessary trigrams, rechecking full pattern on each.
548+ This example finds ` connection ` plus ` refused ` or ` timed out ` via the
549+ ` gin_re2_ops ` GIN index and visits only rows containing necessary trigrams,
550+ rechecking the full pattern on each:
549551
550552``` sql
551553CREATE INDEX ON logs USING gin (msg gin_re2_ops);
0 commit comments