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

LP:917990 - Bad estimate of the number of rows in derived table with LIMIT clause

    Details

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

      Description

      If the table expression for a derived table contains a LIMIT clause then the estimate of the number of rows read from the derived table may be badly off in mariadb-5.3:

      MariaDB [test]> create table t1 (a int);
      Query OK, 0 rows affected (0.02 sec)

      MariaDB [test]> insert into t1 values
      -> (8), (3), (4), (7), (9), (5), (1), (2);
      Query OK, 8 rows affected (0.00 sec)
      Records: 8 Duplicates: 0 Warnings: 0

      MariaDB [test]> select * from (select * from t1 limit 3) t;
      ------

      a

      ------

      8
      3
      4

      ------
      3 rows in set (0.00 sec)

      MariaDB [test]> explain select * from (select * from t1 limit 3) t;
      ------------------------------------------------------------------+

      id select_type table type possible_keys key key_len ref rows Extra

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

      1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8  
      2 DERIVED t1 ALL NULL NULL NULL NULL 8  

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

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            igor Igor Babaev added a comment -

            Re: Bad estimate of the number of rows in derived table with LIMIT clause
            Lp bug #916551 is a duplicate of this bug.

            Show
            igor Igor Babaev added a comment - Re: Bad estimate of the number of rows in derived table with LIMIT clause Lp bug #916551 is a duplicate of this bug.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 917990

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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: