• MySQL存储过程的调优过程


    1. mysql> SELECT whatstheweatherlike(5);
    2. +----------------------------------------------------------+
    3. | whatstheweatherlike(5)                                   |
    4. +----------------------------------------------------------+
    5. | Its 5°C, time IS 02:28:05, feels [LIKE] almost summer!   |
    6. ----------------------------------------------------------+
    7.  row IN SET (0.00 sec)
    8.  
    9. host # tail /var/log/mysql/mysql-slow.log

    可见只显示了对stored-routine的时间记录,并没有对内部的语句的详细运行状况的提示。
    这种情况下,可以使用profile进行调优。

    过程如下:

    1. mysql> SET profiling=1;
    2. Query OK, 0 rows affected (0.00 sec)
    3.  
    4. mysql> SELECT whatstheweatherlike(3);
    5. +-----------------------------------------------------------+
    6. | whatstheweatherlike(3)                                    |
    7. +-----------------------------------------------------------+
    8. | Its 3°C, time IS 02:43:25, feels [LIKE] snow IS melting   |
    9. +   -----------------------------------------------------------+
    10.  row IN SET (0.00 sec)
    11.  
    12. mysql> SHOW profiles;
    13. +----------+------------+-------------------------------------------------------------+
    14.  Query_ID | Duration   | Query                                                       |
    15. +----------+------------+-------------------------------------------------------------+
    16.         1 | 0.00005100 | SELECT CURTIME() INTO time                                  |
    17. |        2 | 0.00014100 | SELECT feeling INTO feels FROM weather WHERE temp = in_temp |
    18. +----------+------------+-------------------------------------------------------------+
    19. rows IN SET (0.00 sec)

    这样就能看到存储过程内部语句的执行情况了。

  • 相关阅读:
    C语言文法修改
    C语言文法
    词法分析程序实验报告
    php设置http响应头和数据库查询字符集编码
    提交form前先使用JS进行验证
    iOS 移动端清除按钮的默认样式
    innerText与textContent的异同
    JS事件应用
    docker redis安装
    cmder的快捷键
  • 原文地址:https://www.cnblogs.com/buro79xxd/p/1682554.html
Copyright © 2020-2023  润新知