PDO语句执行时间
如何使用 PDO 确定语句在数据库服务器上执行所花费的时间?
我正在使用MySQL。大多数 MySQL 客户端实用程序似乎都能够显示查询在服务器上运行的时间,而不管总时间(包括通过网络传输结果)。这让我相信本机 MySQL API 在某处提供了此信息。是否暴露在PDO中?如果是这样,我怎样才能得到它?
注意:我发现了MySQL查询方法,但如果执行时间已在其他地方跟踪,则不希望仅为此执行更多语句。如果不是,那么我将求助于这种方法。
How can I determine the time a statement took to execute on the database server with PDO?
I am using MySQL. Most MySQL client utilities seem to be able to show how long a query ran on the server, irrespective of the total time which includes the transfer of the result over the network. This leads me to believe that the native MySQL API offers this information somewhere. Is it exposed in PDO? If so, how can I get to it?
Note: I have found a MySQL query method, but would prefer not to execute more statements just for this if the execution time is already kept track of somewhere else. If it isn't, then I will fall back on this method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来PDO层没有办法做到这一点。回想起来,这很有意义,因为 PDO 抽象了所有特定于数据库的功能。
It seems that there is no way to do this at the PDO layer. In retrospect, this makes quite a bit of sense, since PDO is abstracting all of the DB-specific features away.