确定 SQLite 中查询的执行时间 [英] Determining execution time of queries in SQLite

查看:53
本文介绍了确定 SQLite 中查询的执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个用于分析和生成查询的程序.我很好奇 SQLite 目前是否存在一种方法,以便我可以查询处理查询所需的时间?我无法以任何方式修改我的安装,因此此方法需要开箱即用.我正在用 python 编写我的工具,虽然我想我可以使用计时器类来计时执行 - 当我连接到远程机器(并返回一致的时间)时,此方法将不起作用.

I am creating a program for analyzing and generating queries. I was curious if there currently exists a method within SQLite such that I could query the time taken for a query to process? I am unable to modify my install in any way, so this method needs to work out of the box. I am writing my tool in python, and although I guess I could use the timer class to time execution -this method will not work when I am connecting to remote machines (and return a consistent timing.)

推荐答案

在 sqlite3 命令行程序中,您可以执行以下操作:

From within the sqlite3 command-line program you can do:

.timer ON
select * from my_table;

这将打印查询所用的 CPU 时间.

This will print the CPU time taken for the query.

这篇关于确定 SQLite 中查询的执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆