DavidG
DavidG

Reputation: 179

How to fix slow queries at one go?

I've enabled slow query log in Mysql for the queries that take time more than 3 seconds. Now when I checked the log, there are more than a hundred thousand slow queries logged. Now I want to fix these slow queries but these are too many to fix one by one. So how should I go about it ?

Is there any alternative to improve all the slow queries ?

Thanks

Upvotes: 2

Views: 293

Answers (1)

Gordan Bobić
Gordan Bobić

Reputation: 1858

You need to summarize your slow logs on a per-query-template basis. Put your log through either of the following:

1) mysqldumpslow -s t [path-to-file/filename.log]

2) pt-query-digest [path-to-file/filename.log]

and that will give you the query templates in order of significance of impact on performance. Fix the performance for one query of that pattern and you'll fix it for all of them.

Upvotes: 1

Related Questions