让MySQL为我们记录执行流程

让MySQL为我们记录执行流程

我们可以开启profiling,让MySQL为我们记录SQL语句的执行流程

  • 查看profiling参数

    shell > select @@profiling;
    
  • 进行更改

    shell > set profiling = 1;
    
  • 执行语句

    select * from employees limit 100;
    
  • 查看该语句执行流程

    show profile;
    

    分别是

    • 启动
    • 权限检查
    • 打开表
    • 初始化表
    • 锁系统
    • 优化查询
    • 统计
    • 优化
    • 执行
    • 发送数据
    • 结束
    • 查询结束
    • 关闭表
    • 释放
    • 清理
  • 请注意上述命令与下面的不同

    show profiles;
    

    显示完成每条指令的所花费的时间

猜你喜欢

转载自www.cnblogs.com/G-Aurora/p/13179749.html