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

EXPLAIN shows meaningless query plan with Distinct

Details

    Description

      Take the attached dataset and run this query:

      explain  select distinct count(*) from t2 where a between 10 and 20 group by a;
      +------+-------------+-------+-------+---------------+------+---------+------+------+---------------------------------------------------------------------+
      | id   | select_type | table | type  | possible_keys | key  | key_len | ref  | rows | Extra                                                               |
      +------+-------------+-------+-------+---------------+------+---------+------+------+---------------------------------------------------------------------+
      |    1 | SIMPLE      | t2    | range | a             | a    | 5       | NULL |   10 | Using where; Using index; Distinct; Using temporary; Using filesort |
      +------+-------------+-------+-------+---------------+------+---------+------+------+---------------------------------------------------------------------+

      and see an apparently non-sensical output (how can a table use "Distinct" if it
      is the only table in the join?)

      This is repeatable on 10.0.17, didn't check 5.5

      Attachments

        Activity

          psergei Sergei Petrunia created issue -
          psergei Sergei Petrunia made changes -
          Field Original Value New Value
          Labels explain
          elenst Elena Stepanova made changes -
          Affects Version/s 5.3.13 [ 12602 ]
          Affects Version/s 10.1 [ 16100 ]
          Affects Version/s 5.5 [ 15800 ]
          Assignee Sergei Petrunia [ psergey ]
          Labels explain explain verified
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 60504 ] MariaDB v3 [ 67256 ]
          psergei Sergei Petrunia made changes -
          Fix Version/s 10.2.0 [ 20700 ]
          Fix Version/s 10.0 [ 16000 ]
          Fix Version/s 10.1 [ 16100 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 67256 ] MariaDB v4 [ 149046 ]

          People

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