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

LP:797687 - Inconsistent costs for group by queries with and without index access

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.3.12, 5.5.36, 10.0.9, 10.6, 10.11, 10.5(EOL)
    • 10.11
    • None

    Description

      The following example over the world database from the 5.3/mysql-test/include directory
      shows that a query that uses an index access to compute GROUP BY has the same cost
      as the same query without index access (using temp table). At the same time the two
      different query plans indeed show different number of Handler_read_* calls.

      Test script:

      create database world;
      use world;
       
      --source include/world_schema.inc
      --source include/world.inc
       
      create index cityname on City(Name);
       
      explain
      SELECT name FROM City GROUP BY name HAVING Count(*) > 2;
      flush status;
      SELECT name FROM City GROUP BY name HAVING Count(*) > 2;
      show status like 'last_query_cost';
      show status like 'Handler_read%';
       
      explain
      SELECT name FROM City ignore index (cityname) GROUP BY name HAVING Count(*) > 2;
      flush status;
      SELECT name FROM City ignore index (cityname) GROUP BY name HAVING Count(*) > 2;
      show status like 'last_query_cost';
      show status like 'Handler_read%';
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            timour Timour Katchaounov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.