Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-29944

[Question] ANALYZE or EXPLAIN for previous query

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Server
    • None

    Description

      Hello,

      `EXPLAIN SELECT ...` shows the EXPLAIN for a query that never runs.

      `SHOW EXPLAIN FOR conn_id` shows the EXPLAIN for a query that is currently running.

      Is it possible to get the EXPLAIN for the last query that ran on a connection?

      For example, if my application detected that a specific query took over 2 seconds to run for a user, I'd like to log the `EXPLAIN` or `ANALYZE` with the query plan of that query.

      I'm not sure that re-running the query with `EXPLAIN` or `ANALYZE` will give me the exact query plan that was used on its previous run, as MariaDB could potentially use another query plan on the re-run.

      (I am aware of `log_slow_verbosity=query_plan,explain`, but I don't want to log this for every query that takes over 1 second - only this specific query)

      Thank you very much!

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nunop Nuno
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.