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

optimizer is wrong

    XMLWordPrintable

Details

    Description

      I compared the "explain" output of two select count(*) from table, identical tables, one mariadb and the other "mysql 8.3", and they are different. The tables have one single field, varchar(10) and it's the primary key. I need to understand the difference:

      Mariadb:

      explain extended select count(*) from goodnumber force index(primary);
       
      +------+-------------+------------+------+---------------+------+---------+------+-----------+----------+-------+
      | id   | select_type | table      | type | possible_keys | key  | key_len | ref  | rows      | filtered | Extra |
      +------+-------------+------------+------+---------------+------+---------+------+-----------+----------+-------+
      |    1 | SIMPLE      | goodnumber | ALL  | NULL          | NULL | NULL    | NULL | 315011080 |   100.00 |       |
      +------+-------------+------------+------+---------------+------+---------+------+-----------+----------+-------+, 
      Mysql, explain select count(*) from goodnumber;
      +----+-------------+------------+------------+-------+---------------+---------+---------+------+-----------+----------+-------------+
      | id | select_type | table      | partitions | type  | possible_keys | key     | key_len | ref  | rows      | filtered | Extra       |
      +----+-------------+------------+------------+-------+---------------+---------+---------+------+-----------+----------+-------------+
      |  1 | SIMPLE      | goodnumber | NULL       | index | NULL          | PRIMARY | 42      | NULL | 315054340 |   100.00 | Using index |
      +----+-------------+------------+------------+-------+---------------+---------+---------+------+-----------+----------+-------------+.
      

      The fastest result is the latter, like 10 times. Does it mean that the commercial version of MySQL by Oracle has a better optimizer and it counts the records on a table about 10 times faster?

      Attachments

        1. mdev33446-log-11.0.txt
          3 kB
          Sergei Petrunia
        2. mdev33446-log-10.11.txt
          3 kB
          Sergei Petrunia

        Issue Links

          Activity

            People

              alice Alice Sherepa
              philip_38 Philip orleans
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.