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

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.
主站蜘蛛池模板: 和林格尔县| 当雄县| 进贤县| 定陶县| 阿城市| 玉环县| 胶南市| 专栏| 西林县| 徐州市| 沙洋县| 旬邑县| 甘南县| 梁平县| 都江堰市| 响水县| 六安市| 军事| 西安市| 张家港市| 乌兰察布市| 宁波市| 洛扎县| 辽宁省| 客服| 雅安市| 吉安市| 耿马| 偃师市| 横山县| 安平县| 辽阳市| 团风县| 白河县| 遂川县| 白朗县| 莱西市| 什邡市| 托克逊县| 嘉兴市| 从化市|