tags:

views:

82

answers:

2

I have a server and many websites, i want to see the most common queries so that to optimize them.

Do you know any tool or any way to collect some statistics ? Thank you

+3  A: 

Since in your last question you seemed to be uninterested in solutions that you don't already have installed, here's a solution that uses only common POSIX commands:

grep 'Query' general-query.log |
  sed -e 's/.* Query       //'  |
  sort | uniq -c | sort -n

Depending on the size of your MySQL general query log, this might take a while to run.

Bill Karwin
PS: there's a literal tab character after `Query` in the sed command, but it got expanded into spaces when I pasted the command.
Bill Karwin
not good "select * from users where user = 'nikos'"and "select * from users where user = 'andreas'"for my purpose is the same querieHow do i generate the general-query.log ?
Nikos
See http://dev.mysql.com/doc/refman/5.1/en/query-log.html for information on how to configure MySQL to output the general query log.
Bill Karwin
+1  A: 

Not sure about all queries, but you can log slow queries for optimization

http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

Midhat
I don't have any slow sql queries because the limit for mysql slow is seconds, and no query is more than a second
Nikos