如何在mysql中获取加载时间(以毫秒或微秒为单位)
我已经搜索了很多,但是找不到一个简单的方法来获得它:
I' ve searched and searched, but I wasn't able to find an easy way to get this:
Query OK, 50000 rows affected (0.35 sec)
以毫秒或微秒为单位.
我该如何实现?
该时间是由mysql监视应用程序计算的,而不是由mysql服务器完成的.您不能通过执行(例如)select last_query_execution_time()
(这很好)来以编程方式检索该东西.
That time's calculated by the mysql monitor application and isn't done by the mysql server. It's not something you can retrieve programatically by doing (say) select last_query_execution_time()
(which would be nice).
您可以通过在应用程序中进行计时,在调用查询函数之前和之后占用系统时间来粗略地模拟它.希望与mysql部分相比,客户端的开销将最小.
You can simulate it in a coarse way by doing the timing in your application, by taking system time before and after calling the query function. Hopefully the client-side overhead would be minimal compared to the mysql portion.