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

LP:916551 - Derived table optimization has wrong estimates for ORDER BY ... LIMIT

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      If I load mysql-test/include/world{_schema,}.inc and run the following query:

      MariaDB [world]> explain select * from (select * from Country order by Population ASC limit 10) as small_country ;
      ---------------------------------------------------------------------------+

      id select_type table type possible_keys key key_len ref rows Extra

      ---------------------------------------------------------------------------+

      1 PRIMARY <derived2> ALL NULL NULL NULL NULL 239  
      2 DERIVED Country ALL NULL NULL NULL NULL 239 Using filesort

      ---------------------------------------------------------------------------+
      2 rows in set (0.00 sec)

      I get 239 as the number of rows which will be scanned in table <derived2>.

      This estimate is wrong, it should be easy to figure that "LIMIT 10" caps table
      size to 10 rows.

      Attachments

        Activity

          People

            igor Igor Babaev
            psergei Sergei Petrunia
            Votes:
            0 Vote for this issue
            Watchers:
            0 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.