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

  • 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.
主站蜘蛛池模板: 曲周县| 临清市| 化德县| 三原县| 湄潭县| 伊宁市| 景谷| 那坡县| 泗阳县| 遵义市| 武邑县| 余姚市| 广西| 壤塘县| 永修县| 大洼县| 武城县| 罗定市| 九龙县| 涡阳县| 长沙市| 甘泉县| 青冈县| 诏安县| 东乌珠穆沁旗| 呼伦贝尔市| 平安县| 汉沽区| 张家川| 南涧| 安西县| 娱乐| 鄂尔多斯市| 苏尼特左旗| 南城县| 如皋市| 天祝| 奉新县| 四川省| 阳泉市| 洛浦县|