分析MySQL语句查询性能的方法除了使用 EXPLAIN 输出执行计划,还可以让MySQL记录下查询超过指定时间的语句,我们将超过指定时间的SQL语句查询称为“慢查询”。
如果启用了慢查询日志,则查询将记录到慢查询日志文件中。
If the slow query log is enabled, the query is logged to the slow query log file.
如您所见,查询执行了三次,平均运行时间大约是307秒,非常慢。
As you can see, the query was executed three times, and the average elapsed time is about 307 seconds, which is very slow.
在我的测试中,虚表上的查询比做同样查询的TimeSeries函数要慢一个数量级。
In my tests, it can be an order of magnitude slower than a TimeSeries function that does the same query.
应用推荐