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

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.
主站蜘蛛池模板: 桓台县| 西峡县| 怀仁县| 五台县| 富裕县| 康平县| 永吉县| 山阴县| 拉萨市| 蒲城县| 黎川县| 江山市| 吉木萨尔县| 曲周县| 绥阳县| 黄石市| 丰台区| 乌苏市| 宜都市| 迁西县| 博乐市| 彭州市| 溧阳市| 绥江县| 寿宁县| 四会市| 嘉定区| 安顺市| 天镇县| 嘉善县| 平邑县| 横山县| 建平县| 阳山县| 磴口县| 襄城县| 江北区| 衡山县| 岑巩县| 独山县| 云梦县|