有没有一个工具可以分析 sqlite 查询?
我正在使用 SQLite 数据库,并且希望通过索引或完全重组它们来加快查询速度。
是否有一个工具可以分析查询,可以帮助我确定哪些地方速度变慢?
我知道我可以将查询输入到像 SQLite Administrator 这样的工具中来计时,但我正在寻找比这更系统的东西——也许是一些位于后台并查看我在一个数据库中输入的所有查询的东西。期间,给出任何瓶颈的分解。
I am using a SQLite database and would like to speed up my queries, perhaps with indexes or by restructuring them altogether.
Is there a tool to profile queries, that might help me decide where things are slowing down?
I know I could just enter queries into a tool like SQLite Administrator to time them, but I'm looking for something a bit more systematic than that -- perhaps something that sits in the background and looks at all the queries that I enter over a period, giving a breakdown of any bottle necks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这只能回答问题的一部分(不幸的是,这是最无用的部分)。
我用谷歌搜索了这个,因为我正在寻找一些东西来计时查询,而 sqlite3 客户端有一个计时器元命令。
sqlite> .timer on
从那里开始,所有查询结果都将附加 cpu 计时器统计信息。
希望这至少有一点帮助。
This will only answer one part of the question (the most unhelpful part, unfortunately).
I googled this up because I was looking for something to time queries and the sqlite3 client has a timer meta command.
sqlite> .timer on
from there on in, all query results will have cpu timer statistics appended.
Hope this helps at least a little bit.
你在这里有各种各样的问题。要查看运行的查询以及每个查询需要多长时间,您需要修改 sqlite3.dll(如果应用程序链接到该应用程序)或者如果它是您自己的应用程序,您可以更轻松地将其写入代码中(我们这样做并长期执行)查询、交易、计时等)。
对于单个查询分析,您可以使用
EXPLAIN
。它不会告诉您查询中各个步骤的时间,但会告诉您查询是如何执行的。http://www.sqlite.org/lang_explain.html
You have a mix of questions in here. To view what queries are run and how long each takes, you'll need to either modify sqlite3.dll if an application is linking to that or if it's your own application you can write it into your code easier (we do this and long all queries, transactions, timings, etc.).
For individual query analysis, you can use
EXPLAIN
. It won't tell you timing of individual steps within a query but it will tel you how the query was executed.http://www.sqlite.org/lang_explain.html
现在 SQLite 有实验性的
sqlite3_trace
和sqlite3_profile
(请参阅 https://www.sqlite.org/c3ref/profile.html 了解详细信息)。它们可以在长时间测试期间统计/调查罪魁祸首时派上用场。Now SQLite has experimental
sqlite3_trace
andsqlite3_profile
(see https://www.sqlite.org/c3ref/profile.html for details). They can come in handy for having statistics/investigating culprit during long tests.这个古老的话题值得一个现代的答案:是。
使用 SQLite 客户端,您可以启用以下功能来帮助您在进行查询时进行基准测试和分析迭代它们:
.timer on
将计时信息输出到 stdout,例如.eqp full
为查询启用EXPLAIN QUERY PLAN
.trace stdout --profile
启用分析器输出,例如这种有状态的方法效果很好如果您正在使用
.read
分析文件中的现有查询,并且您不想手动修改解释语句。您可以使用.parameter set提供查询参数
用于参数化查询。This old thread deserves a modern answer: yes.
With the SQLite client, you can enable the following features to help you benchmark and profile your queries as you iterate on them:
.timer on
to output timing information to stdout, e.g..eqp full
to enableEXPLAIN QUERY PLAN
for your queries.trace stdout --profile
to enable profiler output, e.g.This stateful approach works nicely if you are profiling existing queries from files with
.read <file>
and you do not want to manually hack in explain statements. You can provide query parameters with.parameter set <name> <value>
for parameterized queries.