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

  • 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.
主站蜘蛛池模板: 高陵县| 武胜县| 巴东县| 固镇县| 仁寿县| 东明县| 沁阳市| 高邮市| 枝江市| 田阳县| 银川市| 广昌县| 绩溪县| 乾安县| 皮山县| 恩平市| 甘孜县| 长葛市| 安陆市| 宁河县| 余干县| 霍城县| 东阳市| 玉林市| 阳高县| 荔浦县| 浪卡子县| 双峰县| 扶绥县| 包头市| 平邑县| 自贡市| 德庆县| 徐闻县| 双鸭山市| 鹿泉市| 大悟县| 法库县| 恭城| 南岸区| 民勤县|