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

EXPLAIN shows wrong rows value for LIMIT in derived tables

Details

    Description

      (This is likely to to affect other versions also)

      create table t1 (a int, b int, key(a));
      insert into t1 select seq,seq from seq_1_to_10000;
      

      explain with T as (select a, b from t1 order by a limit 10) select * from T;
      +------+-------------+------------+-------+---------------+------+---------+------+-------+-------+
      | id   | select_type | table      | type  | possible_keys | key  | key_len | ref  | rows  | Extra |
      +------+-------------+------------+-------+---------------+------+---------+------+-------+-------+
      |    1 | PRIMARY     | <derived2> | ALL   | NULL          | NULL | NULL    | NULL | 10    |       |
      |    2 | DERIVED     | t1         | index | NULL          | a    | 5       | NULL | 10157 |       |
      +------+-------------+------------+-------+---------------+------+---------+------+-------+-------+
      

      when running the derived table's SELECT on its own:

      explain select a, b from t1 order by a limit 10;
      +------+-------------+-------+-------+---------------+------+---------+------+------+-------+
      | id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra |
      +------+-------------+-------+-------+---------------+------+---------+------+------+-------+
      |    1 | SIMPLE      | t1    | index | NULL          | a    | 5       | NULL | 10   |       |
      +------+-------------+-------+-------+---------------+------+---------+------+------+-------+
      

      Attachments

        Issue Links

          Activity

            People

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