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

ANALYZE FORMAT=JSON: r_engine_stats.pages_read_time_ms has wrong scale

    XMLWordPrintable

Details

    Description

      Discovered this in MDEV-33446,
      https://jira.mariadb.org/browse/MDEV-33446?focusedCommentId=282972&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-282972

                "r_table_time_ms": 1 425 235.95,
                "r_other_time_ms": 397318.6493,
                "r_engine_stats": {
                  "pages_accessed": 1850995,
                  "pages_read_count": 35272,
                  "pages_read_time_ms": 14 657 261.27
                },
      

      ^ an ANALYZE output where the value of r_engine_stats.pages_read_time_ms doesn't make much sense: it is larger than the query's total r_total_time_ms.

      The cause

      Code from MDEV-31577:
      trace_engine_stats():

            writer->add_member("pages_read_time_ms").
              add_double(hs->pages_read_time / 1000.0);
      

      it's divided by 1000, because according the definition it's microseconds:

      class ha_handler_stats
      {
      ...
        ulonglong pages_read_time;             /* Time reading pages, in microsec. */
      

      On the other hand, it is printed into the slow query log like this: MYSQL_QUERY_LOG::write():

            double tracker_frequency= timer_tracker_frequency();
            sprintf(query_time_buff, "%.4f", 
                    1000.0 * ulonglong2double(stats->pages_read_time)/
                    tracker_frequency);
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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