我創建一個表使用這種模式:如何提高SQLite的LIKE語句性能
CREATE TABLE wordIndex(id integer primary key, word varchar(128), offset integer, length integer);
CREATE INDEX word_idx on wordIndex(word);
現在的表有45萬行records.When我使用Like語句下面就ipod4,表現並不好: 從wordIndex中選擇*,其中的單詞如'test acces%'; 使用EXPLAIN輸出:
explain select * from wordIndex where word like 'test acces%';
0|Trace|0|0|0||00|
1|Goto|0|16|0||00|
2|OpenRead|0|2|0|4|00|
3|Rewind|0|14|0||00|
4|String8|0|2|0|test acces%|00|
5|Column|0|1|3||00|
6|Function|1|2|1|like(2)|02|
7|IfNot|1|13|1||00|
8|Rowid|0|4|0||00|
9|Column|0|1|5||00|
10|Column|0|2|6||00|
11|Column|0|3|7||00|
12|ResultRow|4|4|0||00|
13|Next|0|4|0||01|
14|Close|0|0|0||00|
15|Halt|0|0|0||00|
16|Transaction|0|0|0||00|
17|VerifyCookie|0|2|0||00|
18|TableLock|0|2|0|wordIndex|00|
19|Goto|0|2|0||00|
可能是我需要建立一個額外的倒排索引,以提高性能還是...? 感謝提前!
是否只使用這種模式像(即開頭)? –
是的,只是「aaa%」模式 – ericfang