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

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| 离岛区| 呼和浩特市| 桐庐县| 通化市| 长子县| 龙岩市| 石河子市| 阜平县| 武冈市| 宿松县| 威信县| 玛沁县| 论坛| 昌平区| 吴桥县| 启东市| 鹤山市| 荥阳市| 吴桥县| 京山县| 安康市| 玛沁县| 梅州市| 家居| 乾安县| 上思县| 颍上县| 靖远县| 米林县| 锦屏县| 天门市| 镇平县| 衢州市| 蕲春县| 陕西省| 长沙市| 玛沁县| 玉屏| 无棣县| 普格县|