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

Setting aggregate result to local variable can change query plan

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.0.26, 10.1.18
    • Fix Version/s: 10.2
    • Component/s: Optimizer
    • Labels:
      None

      Description

      MariaDB [RHE_MANAGER]> explain SELECT MAX(`CT_ID`) FROM `CONTRATS`;
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra                        |
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------------------+
      |    1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | Select tables optimized away |
      +------+-------------+-------+------+---------------+------+---------+------+------+------------------------------+
      1 row in set (0.00 sec)
       
        
      explain SELECT @max:=MAX(`CT_ID`) FROM `CONTRATS`;
      +------+-------------+----------+-------+---------------+--------------+---------+------+---------+-------------+
      | id   | select_type | table    | type  | possible_keys | key          | key_len | ref  | rows    | Extra       |
      +------+-------------+----------+-------+---------------+--------------+---------+------+---------+-------------+
      |    1 | SIMPLE      | CONTRATS | index | NULL          | CT_EXPORTRHI | 2       | NULL | 2679710 | Using index |
      +------+-------------+----------+-------+---------------+--------------+---------+------+---------+-------------+
      

        Attachments

          Activity

            People

            Assignee:
            psergei Sergei Petrunia
            Reporter:
            stephane@skysql.com VAROQUI Stephane
            Votes:
            1 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.