宝盒官方网站,Divi wordpress 下载,好看的seo网站,汽车网站建设费用mysql存储过程太慢的解决方法#xff1a;首先打开my.cnf配置文件#xff1b;然后添加配置【long_query_time1】#xff1b;接着通过【tail -f /tmp/logs/mysqld.log】命令监控sql#xff1b;最后进行针对性的优化即可。解决方法#xff1a;第一步#xff1a;修改/etc/my.…mysql存储过程太慢的解决方法首先打开my.cnf配置文件然后添加配置【long_query_time1】接着通过【tail -f /tmp/logs/mysqld.log】命令监控sql最后进行针对性的优化即可。解决方法第一步修改/etc/my.cnf文件找到[mysqld] 里面加入#执行的sqllog/tmp/logs/mysqld.log#记录sql执行超过下面设置时间的sqllog-slow-queries /tmp/mysqlslowquery.log#执行时间大于等于1秒long_query_time 1然后你可以tail -f /tmp/logs/mysqld.log 监控所有执行的sql同样的方法可以监控mysqlslowquery.log 为执行时间超过long_query_time 1(秒)的sql语句比如通过第一步我们找到了某一个mysql 自定义函数执行慢func_getDevice(); 执行了15s,但并不知道这个方法里面到底是那一条sql影响了性能那么就有了第二步。第二步进入mysql命令行输入mysql set profiling1;mysql select func_getDevice(1);mysql show profiles;---------------------------------------------| Query_ID | Duration | Query |---------------------------------------------| 1 | 0.00250400 | select * from TDevice |---------------------------------------------1 row in set (0.00 sec)这时候你就会看到一个详细的sql执行列表但默认只记录15条sql如果方法里面的sql比较多那么可以通过设置mysql set profiling_history_size20;mysql show variables like profiling%;-------------------------------| Variable_name | Value |-------------------------------| profiling | ON || profiling_history_size | 15 |-------------------------------2 rows in set (0.00 sec)mysql select func_getDevice(1);mysql show profiles;这是时候就可以准确的看到是那一条sql语句影响了性能,比如 Query_ID1 select * from TDevice 影响了性能;mysql show profile for query 1;详细查看执行一条sql的耗时情况------------------------------------------| Status | Duration |------------------------------------------| (initialization) | 0.000003 || checking query cache for query | 0.000042 || Opening tables | 0.00001 || System lock | 0.000004 || Table lock | 0.000025 || init | 0.000009 || optimizing | 0.000003 |查看表的索引等是否合理通过针对性的优化以提高效率。相关推荐php培训