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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      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.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            psergey Sergei Petrunia added a comment -

            Re: Derived table optimization has wrong estimates for ORDER BY ... LIMIT
            Note that in MySQL 5.6.4-m7 the estimate is correct - it's 10 rows for <derived2>.

            Show
            psergey Sergei Petrunia added a comment - Re: Derived table optimization has wrong estimates for ORDER BY ... LIMIT Note that in MySQL 5.6.4-m7 the estimate is correct - it's 10 rows for <derived2>.
            Hide
            igor Igor Babaev added a comment -

            Re: Derived table optimization has wrong estimates for ORDER BY ... LIMIT
            This is a duplicate of LP bug #917990.

            Show
            igor Igor Babaev added a comment - Re: Derived table optimization has wrong estimates for ORDER BY ... LIMIT This is a duplicate of LP bug #917990.
            Hide
            elenst Elena Stepanova added a comment -

            Re: Derived table optimization has wrong estimates for ORDER BY ... LIMIT
            Fix for bug #917990 released with 5.3.4-rc.

            Show
            elenst Elena Stepanova added a comment - Re: Derived table optimization has wrong estimates for ORDER BY ... LIMIT Fix for bug #917990 released with 5.3.4-rc.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 916551

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 916551

              People

              • Assignee:
                igor Igor Babaev
                Reporter:
                psergey Sergei Petrunia
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: