- 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.
推薦閱讀
- 繪制進(jìn)程圖:可視化D++語(yǔ)言(第1冊(cè))
- 網(wǎng)上沖浪
- Getting Started with Oracle SOA B2B Integration:A Hands-On Tutorial
- Learning Apache Spark 2
- Visual C# 2008開(kāi)發(fā)技術(shù)詳解
- SharePoint 2010開(kāi)發(fā)最佳實(shí)踐
- 四向穿梭式自動(dòng)化密集倉(cāng)儲(chǔ)系統(tǒng)的設(shè)計(jì)與控制
- Learning C for Arduino
- 完全掌握AutoCAD 2008中文版:機(jī)械篇
- 單片機(jī)C語(yǔ)言應(yīng)用100例
- Citrix? XenDesktop? 7 Cookbook
- INSTANT Munin Plugin Starter
- Photoshop CS5圖像處理入門(mén)、進(jìn)階與提高
- Linux系統(tǒng)管理員工具集
- Photoshop CS4數(shù)碼照片處理入門(mén)、進(jìn)階與提高