位置:首页 > 后端 > 数据库

MySQL优化之分析海量数据

chenlong 发布:2021-10-28 14:48:36阅读:

通过profiles分析海量数据

查看是否开启:show variables like ‘%profiling%’;
开启:set profiling = on;
show profiles:会记录所有profiling打开之后的全部SQL语句(只能看到总共的消费时间,不能看到各个硬件消费的时间)


image.png


show profile all for query 2;// 上一步查询的所有

show profile cpu,block io for query 2;


image.png


全局查询日志

记录开启后,全部执行的SQL语句都会记录在mysql_general_log表中
select * from mysql.general_log;

开启全局查询日志
show variables like ‘%general_log%’;// 查看是否开启

set global general_log = 1;// 开启全局日志
set global log_output = ‘table’;// 设置将全部的SQL记录在表中

set global log_output = ‘file’;// 日志记录在文件中
set global general_log = 1;
set global general_log_file=’/tmp/general.log’; //


24人点赞 返回栏目 提问 分享一波

小礼物走一波,支持作者

还没有人赞赏,支持一波吧

留言(问题紧急可添加微信 xxl18963067593) 评论仅代表网友个人 留言列表

暂无留言,快来抢沙发吧!

本刊热文
网友在读
手机扫码查看 手机扫码查看