logging EXPLAIN output of slow queries in MySQL



  • I am trying to understand if there is functionality like auto_explain in PostgreSQL for MySQL. Specifically, I am interested in logging the query plan (not just the query) for all slow queries in MySQL.

    Is there any documentation on whether this is possible or not?



  • MySQL has https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_log_slow_extra which includes some session status variables per https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html , however its not equivalent to an https://dev.mysql.com/doc/refman/8.0/en/explain.html .

    If you are using MariaDB then https://mariadb.com/kb/en/explain-in-the-slow-query-log/ is possible with https://mariadb.com/kb/en/server-system-variables/#log_slow_verbosity




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2