官术网_书友最值得收藏!

  • Mastering PostgreSQL 9.6
  • Hans Jurgen Schonig
  • 100字
  • 2021-07-09 19:57:22

Handling regular expressions

However, this is still not everything. Trigram indexes are even capable of speeding up simple regular expressions. The following example shows how this can be done:

test=# SELECT * FROM t_location WHERE name ~ '[A-C].*neu.*'; 
name
--------------
Bruckneudorf
(1 row)
test=# explain SELECT * FROM t_location WHERE name ~ '[A-C].*neu.*'; 
QUERY PLAN
-----------------------------------------------------------------
Index Scan using idx_trgm on t_location (cost=0.14..8.16
rows=1 width=13)
Index Cond: (name ~ '[A-C].*neu.*'::text)
(2 rows)

PostgreSQL will inspect the regular expression and use the index to answer the question.

Internally, PostgreSQL can transform the regular expression into a graph and traverse the index accordingly.
主站蜘蛛池模板: 光山县| 托里县| 共和县| 会昌县| 美姑县| 新巴尔虎右旗| 周宁县| 武鸣县| 隆安县| 武清区| 呼伦贝尔市| 宽城| 新泰市| 广汉市| 阳谷县| 汾西县| 永平县| 手游| 兴业县| 来凤县| 伊春市| 怀远县| 凉山| 克什克腾旗| 东乌| 英德市| 出国| 临泽县| 神木县| 永顺县| 嘉义县| 应城市| 循化| 宜阳县| 曲周县| 太湖县| 桂林市| 巨鹿县| 伽师县| 桃江县| 如皋市|