I see there is a nice option how to enable log slow queries and queries without indexes:
SET GLOBAL log_queries_not_using_indexes=1;
SET GLOBAL log_slow_queries=1;
OK, OK, but it seems both write in the same log file I have specified at my.cnf configuration file:
[mysqld]
long_query_time = 1
log-slow-queries = /var/log/mysql/mysql-slow.log
I use mysqldumpslow to see the slowest queries, but what I need to do to see separately that queries without indexes?
In addition to a1ex07's answer you can use the shell command mk-query-digest to output a report of your running queries without using the log. Useful to fast detect unindexed queries.
log_queries_not_using_indexes tells MySQL to additionally log all queries that do not use an index to limit the number of rows scanned.
The slow query log consists of SQL statements that take more than long_query_time seconds to execute and require at least min_examined_row_limit rows to be examined. The slow query log can be used to find queries that take a long time to execute and are therefore candidates for optimization.
You can't. The log file is a text file and you can't infer from it whether a query used an index at that time of execution.
Also, the option log-queries-not-using-indexes
doesn't necessarily log queries who aren't using an index, see:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With