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

  • 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.
主站蜘蛛池模板: 旬阳县| 密云县| 开化县| 新田县| 门源| 临沧市| 昌宁县| 芮城县| 临沂市| 内黄县| 贺州市| 黄平县| 宁津县| 东乌珠穆沁旗| 古浪县| 顺平县| 同心县| 玉龙| 砚山县| 临海市| 桓仁| 洪湖市| 乌拉特后旗| 佳木斯市| 寻甸| 依兰县| 芦溪县| 遵化市| 金川县| 原平市| 达州市| 香河县| 屯门区| 鹿泉市| 板桥市| 会理县| 西盟| 铁岭县| 正定县| 都匀市| 分宜县|