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

  • 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.
主站蜘蛛池模板: 黔东| 晋宁县| 册亨县| 南汇区| 方正县| 东乌珠穆沁旗| 乐陵市| 汝南县| 时尚| 沙坪坝区| 无为县| 德格县| 宝清县| 鄯善县| 临桂县| 定襄县| 远安县| 蒙山县| 彭水| 双牌县| 泰来县| 武平县| 阆中市| 辽宁省| 遂平县| 汨罗市| 靖边县| 修文县| 积石山| 中超| 阿合奇县| 农安县| 伊通| 陈巴尔虎旗| 离岛区| 和田市| 巴青县| 开远市| 衡南县| 徐州市| 乌什县|