7

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jakub Mach
  • 1,109
  • 3
  • 10
  • 19

1 Answers1

9

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.

Dor
  • 7,344
  • 4
  • 32
  • 45