mysql慢查询日志操作技法

慢日志查询的操作命令

echo 'select count(1) from mysql.slow_log order by query_time desc limit 5' | mysql  
echo 'select * from mysql.slow_log order by query_time' | mysql | less  

筛选操作

echo 'select sql_no_cache goods_id from datacenters.common_plat_goods limit 1' | mysql

echo 'select sql_no_cache goods_id from datacenters.common_plat_goods where goods_tag like '%关键词%'' | mysql

echo "select sql_no_cache goods_id from datacenters.common_plat_goods where goods_tag like '%关键词%'" | mysql

echo "select sql_no_cache goods_id from datacenters.common_plat_goods where goods_tag like '%关键词%' limit 100, 10" | mysql

 echo "select sql_no_cache count(1) from datacenters.common_plat_goods where goods_tag like '%关键词%'" | mysql

 time echo "select sql_no_cache count(1) from datacenters.common_plat_goods where goods_tag like '%关键词%'" | mysql

time echo "select sql_no_cache count(1) from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode)"| mysql

 time echo "select sql_no_cache SQL_CALC_FOUND_ROWS count(1) from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode)"| mysql
 1503  time echo "select sql_no_cache,SQL_CALC_FOUND_ROWS count(1) from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode)"| mysql

 time echo "select sql_no_cache SQL_CALC_FOUND_ROWS count(1) from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode)"| mysql


time echo "select sql_no_cache SQL_CALC_FOUND_ROWS count(1) from datacenters.common_plat_goods where goods_tag like '%关键词%'" | mysql

time echo "select sql_no_cache SQL_CALC_FOUND_ROWS count(1) from datacenters.common_plat_goods where goods_tag like '%关键词%'; select FOUND_ROWS();" | mysql

  time echo "select sql_no_cache SQL_CALC_FOUND_ROWS * from datacenters.common_plat_goods where goods_tag like '%关键词%' limit 1; select FOUND_ROWS();" | mysql

time echo "select sql_no_cache SQL_CALC_FOUND_ROWS goods_id from datacenters.common_plat_goods where goods_tag like '%关键词%' limit 1; select FOUND_ROWS();" | mysql

 time echo "select sql_no_cache SQL_CALC_FOUND_ROWS goods_id from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode) limit 1; select FOUND_ROWS();"| mysql

 time echo "select sql_no_cache SQL_CALC_FOUND_ROWS goods_id from datacenters.common_plat_goods where goods_tag like '%关键词%' limit 1; select FOUND_ROWS();" | mysql

 time echo "select sql_no_cache SQL_CALC_FOUND_ROWS goods_id from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode) limit 1; select FOUND_ROWS();"| mysql

time echo "select sql_no_cache SQL_CALC_FOUND_ROWS goods_id from datacenters.common_plat_goods where goods_tag like '%关键词%' limit 1; select FOUND_ROWS();" | mysql

time echo "select sql_no_cache SQL_CALC_FOUND_ROWS goods_id from datacenters.common_plat_goods where match(goods_tag) against ('+关键词' in boolean mode) limit 1; select FOUND_ROWS();"| mysql  

axiaoyue

继续阅读此作者的更多文章