32

Just as the title says, where can I see it ?

Are there any config options for it ( like how many ms would determine if a query is slow or not ) ?

poelinca
  • 2,865
  • 3
  • 22
  • 15

5 Answers5

31

In MySQL : show global variables like '%slow%';

Update : here's a link to the manual: link text

RolandoMySQLDBA
  • 185,223
  • 33
  • 326
  • 536
SteveHarville
  • 493
  • 3
  • 7
25

You can find it in the default directory, depending on your install. For instance, on my Red Hat, it's /var/log/mysql/

Query time is time, in seconds, over which it should start recording. This can be done at startup and at runtime.

log-slow-queries = /var/log/mysql/mysql-slow.log

long_query_time = 1

David Hall
  • 2,295
  • 1
  • 18
  • 11
7

These are the pertinent options (and settings) I generally have/use in all my my.cnfs to log slow queries:

log_output=FILE
slow_query_log=1
slow_query_log_file=/var/log/mysql/mysql.slow 
long_query_time=0.001 
log-queries-not-using-indexes=0

Note that for long_query_time,

Beginning with MySQL 5.1.21 ... a resolution of microseconds is supported when logging to a file.

Riedsio
  • 1,377
  • 1
  • 14
  • 18
3

Here is something to consider as well :

If you use the option

log-output=TABLE

in you /etc/my.cnf file, look for the slow log to be a CSV storage engine based table located in, of all places, the mysql schema.

This affects the general log as well, once you enable it.

RolandoMySQLDBA
  • 185,223
  • 33
  • 326
  • 536
3

Search your mysqld config file (usually, /etc/my.cnf)

At your shell:

grep slow /etc/my.cnf
randomx
  • 3,944
  • 4
  • 31
  • 44