V
V
Vadim2014-02-07 15:50:33
MariaDB
Vadim, 2014-02-07 15:50:33

MariaDB. Why is a query written in slow-queries that takes 0.0002 seconds?

In general, the bottom line is that 1 single request is written to the slow query log, which is completed in an average of 0.0002 seconds.
Actually a question: Why the fast request in this broad gull is written?
Config snippet responsible for the logs:

log-queries-not-using-indexes
general-log-file=/var/log/mysql.log
log-error=/var/log/mysql-errors.log
log-slow-queries=/var/log/mysql-slow-queries.log
long-query-time=1

An excerpt from slow-log
use dbName;
SET timestamp=1391776302;
SELECT COUNT(*) FROM FolourOnline WHERE lastVisit > (UNIX_TIMESTAMP() - 120);
# [email protected]: user[user] @ localhost []
# Thread_id: 341  Schema: dbName  QC_hit: No
# Query_time: 0.000131  Lock_time: 0.000042  Rows_sent: 1  Rows_examined: 154

EXPLAIN:
MariaDB [dbName]> EXPLAIN SELECT COUNT(*) FROM FolourOnline WHERE lastVisit > (UNIX_TIMESTAMP() - 120);
+------+-------------+--------------+-------+---------------+-----------+---------+------+------+--------------------------+
| id   | select_type | table        | type  | possible_keys | key       | key_len | ref  | rows | Extra                    |
+------+-------------+--------------+-------+---------------+-----------+---------+------+------+--------------------------+
|    1 | SIMPLE      | FolourOnline | range | lastVisit     | lastVisit | 4       | NULL |  144 | Using where; Using index |
+------+-------------+--------------+-------+---------------+-----------+---------+------+------+--------------------------+
1 row in set (0.00 sec)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question