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

Optimizer Context Replay: handle cheap subqueries

    XMLWordPrintable

Details

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

    Description

      The optimizer may execute subqueries that are CONSTANT and cheap enough. It will then use their value during the optimzation.
      Example:

      create table t10 (a int, b int, index(a));
      insert into t10 select NULL, seq from seq_1_to_10;
      create table t20 (a int, b int, index(a));
      insert into t20 select seq, seq from seq_1_to_10000;
      explain select * from t20 where a < (select max(b) from t10);
      

      +------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
      | id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra       |
      +------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
      |    1 | PRIMARY     | t20   | range | a             | a    | 5       | NULL | 9    | Using where |
      |    2 | SUBQUERY    | t10   | ALL   | NULL          | NULL | NULL    | NULL | 10   |             |
      +------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
      

      How to handle this for context capture/replay?

      Ideas about solution:
      Option 1: Follow the "constant table row" approach: capture the rows read during the subquery execution. Then, re-running the same query plan on this subset of rows should produce the same result.

      Option 2: Save in the context the fact that "Executing subquery #N produced value 'fooo'". Add a hook into subquery execution to put in the value instead of doing the execution.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.