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

Optimizer Trace replay step #2: dump basic statistics

    XMLWordPrintable

Details

    • Q2/2025 Development, Q3/2025 Server Development

    Description

      Dump the table statistics into a JSON section in optimizer trace:

      • number of rows in the table
      • used index statistics, for all key parts in each index.
      • all records_in_range() calls that optimizer has made and their return values.
      • constant lookups the optimizer has made and their results.

      (Note that the above list is not exhaustive. It will need to be enhanced to provide exact same execution. But these variables form a good-enough first step).

      All values should be in user-readable format.

      NOTE: This MDEV doesn't provide the whole optimizer state capture/replay feature, but it's usable on its own so can go into 12.1

      (Further continuation is MDEV-36523)

      Implementation

      A list of things to capture:

      Used Histograms and EITS statistics.

      TODO: do we capture all histograms available or just those that were used?

      records_in_range calls

      SQL layer makes two kinds of calls:

      • multi_range_read_info_const()
      • records_in_range().

      Should we capture both?

      Constant table row reads.

      Just capture what rows were read from the table (right?)
      (Q: or, should we also capture the fact that some rows were read but not found?)

      Optimizer settings in system variables.

      Capture the values of system variables controlling the optimizer:

      • join_cache_level
      • optimizer_prune_level
      • optimizer_search_depth
      • optimizer_switch
      • optimizer_use_condition_selectivity

      MS1 - Dump basic stats

      The goal is to produce JSON like this:

        "records": 123,
        "indexes" : [
          {
            "index_name": "IDX1",
            "rec_per_key": [123, 1230, 123000],
          }
          ...
        ]
      }
      

      The records should come from table->stat_records()
      the rec_per_key from:

        for each index IDX
          write array of key parts:
          for each i
            table->keyinfo[IDX].actual_rec_per_key(i)
      

      MS2 - scan_time()

      TODO: which call to make

      MS3: records_in_range ?

      Attachments

        Issue Links

          Activity

            People

              bsrikanth Srikanth Bondalapati
              psergei Sergei Petrunia
              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.