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

range optimizer costly filesort on indexed column

    XMLWordPrintable

Details

    Description

      explain select `payment_uid`,`date`,`simulation_state` 
      from `stock` 
      where `date` >= '2017-05-31 22:00:00' and `date` <= '2018-05-31 22:00:00' order by date desc;
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-----------------------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows      | Extra                       |
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-----------------------------+
      |    1 | SIMPLE      | stock | ALL  | date          | NULL | NULL    | NULL | 233416309 | Using where; Using filesort |
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-----------------------------+
      1 row in set (0.01 sec)
      

      explain select `payment_uid`,`date`,`simulation_state` 
      from `stock` 
      where `date` >= '2017-05-31 22:00:00' and `date` <= '2018-05-31 22:00:00' order by date ;
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-----------------------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows      | Extra                       |
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-----------------------------+
      |    1 | SIMPLE      | stock | ALL  | date          | NULL | NULL    | NULL | 233416309 | Using where; Using filesort |
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-----------------------------+
      1 row in set (0.00 sec)
      

      explain select `payment_uid`,`date`,`simulation_state` 
      from `stock` 
      where `date` >= '2017-05-31 22:00:00' and `date` <= '2018-05-31 22:00:00';               
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-------------+
      | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows      | Extra       |
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-------------+
      |    1 | SIMPLE      | stock | ALL  | date          | NULL | NULL    | NULL | 233416309 | Using where |
      +------+-------------+-------+------+---------------+------+---------+------+-----------+-------------+
      1 row in set (0.00 sec)
      

      DDL is
      `date` datetime DEFAULT NULL,
      KEY `date` (`date`),

      Important step to reproduce ,
      We copy a 10.1.24 datadir and used mysql_upgrade -s
      The filtered range is 120M rows

      (psergey edited a bit to improve readability)

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              stephane@skysql.com VAROQUI Stephane
              Votes:
              1 Vote for this issue
              Watchers:
              8 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.