codegooglecom / mysql-log-filter

Automatically exported from code.google.com/p/mysql-log-filter
1 stars 0 forks source link

Here is a version that stores the output in a mysql table so you can do further stats on large logs #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The script will drop/create a table called "log_slow_queries_results"
pertinent fields
q_count = times the query was executed
t_time = total time taken
a_time = average time taken
min_time = fastest time
max_time = slowest time
min_rows = min rows examined
max_rows = max rows examined
min_host = min value of user@host
max_host = max value of user@host
min_date = first occurred
max_date = last occurred
min_hour = 0-23 min hour of day query was run
max_hour = 0-23 max hour of day query was run
avg_hour =  0-23 avg hour of day query was run
query = general select statement of query with XXX in criteria
example = example of one of the queries (so you can run explain)

example sql to pull results for slow in last 30 days between 7am and 5pm:

select * from log_slow_queries_results
where avg_hour >= 7 and avg_hour <=17
and max_date > (NOW() - INTERVAL 30 DAY)
and q_count > 20
order by min_rows desc
limit 100

Original issue reported on code.google.com by richard....@gmail.com on 2 Apr 2009 at 6:27

Attachments: