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

  • Mastering PostgreSQL 10
  • Hans Jürgen Sch?nig
  • 100字
  • 2021-06-30 19:03:59

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.
主站蜘蛛池模板: 马公市| 冀州市| 汉寿县| 明水县| 丹阳市| 怀远县| 海林市| 正蓝旗| 罗源县| 永泰县| 安溪县| 二连浩特市| 巴彦县| 房产| 措勤县| 林芝县| 诸城市| 瓦房店市| 张家川| 观塘区| 响水县| 大石桥市| 仪陇县| 衡水市| 始兴县| 武义县| 金堂县| 鄂温| 光山县| 界首市| 盐津县| 奎屯市| 即墨市| 开阳县| 平罗县| 纳雍县| 大兴区| 林州市| 东源县| 班玛县| 台安县|