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

Add ability to track "slow" stored procedures in slow query log

    Details

    • Type: Task
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: 10.1
    • Component/s: None
    • Labels:
      None

      Description

      Please add the ability to track "slow" stored procedures in slow query log.

      Perhaps this could be backported from Percona Server.

      They currently have the option:

      log_slow_sp_statements

      "If TRUE, statements executed by stored procedures are logged to the slow if it is open."

      https://www.percona.com/doc/percona-server/5.5/diagnostics/slow_extended_55.html#log_slow_sp_statements

      There are quite a few more details listed there which may help shed light on the implementation, such as:

      "Prior to 5.5.41-37.0 implementation of logging stored procedures was logging the stored procedure CALLs themselves along with the queries inside the procedures. This meant that some queries were counted more than once which could make tracking the bad-performing queries harder and it would cause noise in the slow query log. Percona Server 5.5.41-37.0 implemented improvements for logging of stored procedures to the slow query log:

      o Each query from a stored procedure is now logged to the slow query log individually
      o CALL itself isn’t logged to the slow query log anymore as this would be counting twice for the same query which would lead to incorrect results
      o Queries that were called inside of stored procedures are annotated in the slow query log with the stored procedure name in which they run."

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            Few considerations:

            • MDEV-7011 statement timeouts. currently max_statement_time limit applies to CALL statement as a whole, not to individual statements in the stored procedure. That was done, precisely, because CALL is logged in the slow query log as a whole, that is, the logic is — we measure time for the CALL, not for statements inside it. If slow query log will contain statements from inside the stored procedure, we might want to change max_statement_time to match this behavior.
            • MDEV-7444 currently audit plugin doesn't see statements inside the stored procedure, we might want to change this too
            • slow log can record EXPLAIN output for statements. it needs to work for statements inside a procedure too
            Show
            serg Sergei Golubchik added a comment - Few considerations: MDEV-7011 statement timeouts. currently max_statement_time limit applies to CALL statement as a whole, not to individual statements in the stored procedure. That was done, precisely, because CALL is logged in the slow query log as a whole, that is, the logic is — we measure time for the CALL, not for statements inside it. If slow query log will contain statements from inside the stored procedure, we might want to change max_statement_time to match this behavior. MDEV-7444 currently audit plugin doesn't see statements inside the stored procedure, we might want to change this too slow log can record EXPLAIN output for statements. it needs to work for statements inside a procedure too

              People

              • Assignee:
                Unassigned
                Reporter:
                ccalender Chris Calender
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: