SQLite FTS3 性能不一致
大约有 100k 行的表。
SELECT word FROM entries WHERE word MATCH '"chicken *"';
17 results in 46ms
SELECT word FROM entries WHERE word MATCH '"chicken f*"';
2 results in 5793ms
为何跌幅如此之大?
A table with ~100k rows.
SELECT word FROM entries WHERE word MATCH '"chicken *"';
17 results in 46ms
SELECT word FROM entries WHERE word MATCH '"chicken f*"';
2 results in 5793ms
Why such a huge drop?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“chicken *”中的通配符可以有效地被忽略,因为它完全匹配任何标记。搜索是反向索引中的简单查找。
“chicken f*”中的通配符需要查找所有以 f 开头且包含“chicken”单词的条目。可以理解的是,它更复杂、更慢。
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.