SQLite FTS3 inconsistent performance
A table with ~100k rows.
SELECT word FROM entries WHERE word MATCH '"c开发者_如何学Pythonhicken *"';
17 results in 46ms
SELECT word FROM entries WHERE word MATCH '"chicken f*"';
2 results in 5793ms
Why such a huge drop?
The wildcard in "chicken *" can effectively be ignored as it matches any token at all. The search is a simple lookup in the reverse index.
The wildcard in "chicken f*" needs to find all entries with words beginning with f, that also contain the word chicken. It is understandably more complicated and slower.
精彩评论