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

  • 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.
主站蜘蛛池模板: 奎屯市| 石渠县| 红原县| 贵南县| 交城县| 灯塔市| SHOW| 永胜县| 大丰市| 丰原市| 兰坪| 微山县| 惠来县| 泰宁县| 茂名市| 十堰市| 镇安县| 竹溪县| 连平县| 工布江达县| 玉溪市| 弥渡县| 鸡泽县| 建始县| 上杭县| 随州市| 济源市| 松原市| 丰原市| 新巴尔虎左旗| 调兵山市| 工布江达县| 黑水县| 罗江县| 瑞昌市| 甘谷县| 叶城县| 衡山县| 涿鹿县| 保亭| 新源县|