Last active
August 29, 2015 14:23
-
-
Save guileen/884d0baa3e73f8073cc5 to your computer and use it in GitHub Desktop.
分析sql日志
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 截取 sql | |
cat sql_detail_log.log | grep Statement | cut -f 9- -d ' ' | sed 's/^ *//g' | tr -s ' ' > sql_clean.log | |
# 截取 sql | |
cat friend_sql_grep.log | cut -f 8- -d ' ' | tr -s ' ' >> sql_clean.log | |
# 去除 where 和 分表 \ | |
# 排序并统计 \ | |
# 规范统计结果 再次排序 | |
cat sql_clean.log | tr '[:upper:]' '[:lower:]' | sed 's/where.*//' | sed 's/_[0-9][0-9]/_XX/' \ | |
| sort | uniq -c \ | |
| sed 's/^\(.... \)/ \1/' | sed 's/^\(..... \)/ \1/' | sort \ | |
> sql_stat.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment