Rajnish
Rajnish

Reputation: 1351

mysql slow log query details about Query_time

I am using mysql : 5.5.31-0ubuntu0.12.04.1-log (Ubuntu) and I enabled slow log query ,slow log query time set is 2 sec for details :

show variables like 'slow_launch_time';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| slow_launch_time | 2     |
+------------------+-------+
1 row in set (0.00 sec)

and in my.cnf :

long_query_time = 2

it means any query takes more than 2 sec, it will stored in mysql slow log query.

when I tried this using select sleep(1) ; select sleep(2) ; select sleep(3) ; and viewed slow log query ,only sleep(2) and sleep(3) saved in slow log query with Query_time: # Query_time: 2.000263 and # Query_time: 3.000278 respectively . but I saw many queries which have Query_time less than 2 sec also saved in slow log query

for more details :

# Query_time: 0.001775  Lock_time: 0.000154 Rows_sent: 1  Rows_examined: 120

why this type of query saved in my slow log , I don't understand ?

Upvotes: 0

Views: 4297

Answers (1)

RandomSeed
RandomSeed

Reputation: 29749

Probably because log_queries_not_using_indexes is on:

If you are using this option with the slow query log enabled, queries that are expected to retrieve all rows are logged. See Section 5.2.5, “The Slow Query Log”. This option does not necessarily mean that no index is used. For example, a query that uses a full index scan uses an index but would be logged because the index would not limit the number of rows.

Upvotes: 1

Related Questions