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

Replay on existing database yields different execution plan

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 12.3
    • 12.3.2
    • Optimizer
    • None
    • Unexpected results
    • Q2/2026 Server Maintenance

    Description

      Bug found while testing MDEV-38701

      Replay should yield same execution plan as when context captured.

      Case:

      ---------
      No indexes in table while capturing context -->Does Table scan
      Index created on table after capturing context

      Issue:

      --------
      Replay on existing data-dir , differs in execution plan
      If replay done on existing database , then create table stmt fails bcz table already exists.
      It uses old table defination which has index , hence differs in execution plan

      While Capturing context : Table scan choosen

      +------+-------------+-------+------+---------------+------+---------+------+-------+-------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows  | Extra |
      +------+-------------+-------+------+---------------+------+---------+------+-------+-------+
      |    1 | SIMPLE      | t1    | ALL  | NULL          | NULL | NULL    | NULL | 10000 |       |
      +------+-------------+-------+------+---------------+------+---------+------+-------+-------+
      

      Replay does : Index scan

      +------+-------------+-------+-------+---------------+------+---------+------+-------+-------------+
      | id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows  | Extra       |
      +------+-------------+-------+-------+---------------+------+---------+------+-------+-------------+
      |    1 | SIMPLE      | t1    | index | NULL          | i1   | 5       | NULL | 10000 | Using index |
      +------+-------------+-------+-------+---------------+------+---------+------+-------+-------------+
      

      Note:

      --------
      Replay done on fresh data directory , then Execution plan is same

      Steps to repro:

      step1) Capture Context
      ----------------------------------
      create database m8;use m8;
      create table t1( a int);
      insert into t1 select seq from seq_1_to_10000;
      set optimizer_record_context=ON;
      explain select * from t1;
      SELECT context INTO DUMPFILE 'context1.txt' FROM INFORMATION_SCHEMA.OPTIMIZER_CONTEXT;
       
      step2) Create index on table
      ----------------------------
      create index i1 on t1(a);
       
      step3) Execute Query
      ----------
      explain select * from t1;
       
      step4) Replay context
      ---------------------------------
      source data2/m8/context1.txt;
      

      Attachments

        Activity

          People

            bsrikanth Srikanth Bondalapati
            mariadb-pavithrapandith Pavithra Pandith
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.