如何分析 Sqlite 查询执行情况?
我有一个 Sqlite 数据库,我想检查索引是否正确。 MS SQL 分析器非常擅长分解查询执行和利用的索引。
Sqlite 有类似的工具吗?
I have a Sqlite database which I want to check the indexes are correct. MS SQL Analyser is great at breaking down the query execution and utilised indexes.
Is there a similar tool for Sqlite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 outis 所说:
如果像我一样,您只是使用它来确保达到索引(索引?),那么是否可以提供更具可读性的输出?
As outis said:
Does the trick with a more readable output, if like me you're simply using it to ensure you're hitting your indexes (indices?)
据我所知,没有漂亮的图形工具,但您寻找的所有信息都可以通过
EXPLAIN
关键字获得。考虑这个数据库:
基于
email
的查询不会使用索引:而基于 name 的查询将使用
user_names
索引:使用
EXPLAIN
确实需要掌握 SQLite 的虚拟机 VDBE:http://www.sqlite.org/opcode.html
但这并不像看起来那么难,并且为您提供了有关查询的完整故事。
I know of no pretty graphical tools, but all of the information you seek is available from the
EXPLAIN
keyword.Consider this database:
A query predicated on
email
will not use an index:Whereas a query predicated on name will use the
user_names
index:Using
EXPLAIN
does require coming to grips with SQLite's virtual machine, VDBE:http://www.sqlite.org/opcode.html
But this is not as hard as it looks, and gives you the complete story about your query.
有一个很好的图形工具
https://github.com/asutherland/grok-sqlite-explain
这是输出示例:
以及相关博文:
http://www. visophyte.org/blog/2010/04/06/performance-annotated-sqlite-explaination-visualizations-using-systemtap/
There's this nice graphical tool
https://github.com/asutherland/grok-sqlite-explain
Here's example of output:
And associated blogpost:
http://www.visophyte.org/blog/2010/04/06/performance-annotated-sqlite-explaination-visualizations-using-systemtap/