分析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.
因此,如果查询筛选字段是这种类型中的一个,而相关的表格很大,那么查询的速度会非常慢。
Therefore, if a query filter field is one of these types, and the associated table is large, the query can be very slow.
应用推荐