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

InnoDB's doubling of rec_per_key estimates causes poor query plans

    XMLWordPrintable

Details

    Description

      InnoDB is known to produce overly-optimistic index estimates for index lookups.
      This was done intentionally, see this piece in ha_innobase::info_low:

                                      /* Since MySQL seems to favor table scans
                                      too much over index searches, we pretend
                                      index selectivity is 2 times better than
                                      our estimate: */
       
                                      rec_per_key_int = rec_per_key_int / 2;
      

      However in some cases that can cause poor query plans.

      in 11.0, this was removed by this commit:

      commit 01c82173dd8b6ea627dec949dbc57dfcc94a656d
      Author: Monty <monty@mariadb.org>
      Date:   Thu Jan 26 11:38:31 2023 +0200
       
          Removed /2 of InnoDB ref_per_key[] estimates
          
          The original code was there to favor index search over table scan.
          This is not needed anymore as the cost calculations for table scans
          and index lookups are now more exact.
      

      This MDEV is about adding a capability to remove the /2 in versions before 11.0

      Attachments

        Activity

          People

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