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

Add optimizer_adjust_secondary_key_costs variable

Details

    Description

      The reason behind this change is that MariaDB 10.x does not take into
      account that for engines like InnoDB, that scanning a primary key can be up
      to 7x faster than scanning a secondary key + read the row data trough the
      primary key.

      optimizer-adjust_secondary_key_costs is added to provide 2 small
      adjustments to the 10.x optimizer cost model. This can be used in the
      case where the optimizer wrongly uses a secondary key instead of a
      clustered primary key.

      The different values for the new variable:

      optimizer_adjust_secondary_key_costs=0 (default)

      • No changes to current model

      optimizer_adjust_secondary_key_costs=1

      • Ensure that the cost of of secondary indexes has a cost of at
        least 5x times the cost of a primary key.
        This disables part of the worst_seek optimization described below.

      optimizer_adjust_secondary_key_costs=2

      • Disable "worst_seek optimization and adjust filter cost slightly
        (add cost of 1 if filter is used).

      Attachments

        Issue Links

          Activity

            monty Michael Widenius created issue -
            serg Sergei Golubchik made changes -
            Field Original Value New Value
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.6.17 [ 29518 ]
            serg Sergei Golubchik made changes -
            Assignee Michael Widenius [ monty ]
            serg Sergei Golubchik made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            monty Michael Widenius made changes -
            Description The reason behind this change is that MariaDB 10.x does not take into
            account that for engines like InnoDB, that scanning a primary key can be up
            to 7x faster than scanning a secondary key + read the row data trough the
            primary key.

            optimizer-adjust_secondary_key_costs is added to provide 2 small
            adjustments to the 10.x optimizer cost model. This can be used in the
            case where the optimizer wrongly uses a secondary key instead of a
            clustered primary key.

            The different values for the new variable:

            optimizer_adjust_secondary_key_costs=0
            - No changes to current model

            optimizer_adjust_secondary_key_costs=1
            - Ensure that the cost of of secondary indexes has a cost of at
              least 5x times the cost of a primary key.
              This disables part of the worst_seek optimization described below.

            optimizer_adjust_secondary_key_costs=2
            - Disable "worst_seek optimization and adjust filter cost slightly
              (add cost of 1 if filter is used).
            The reason behind this change is that MariaDB 10.x does not take into
            account that for engines like InnoDB, that scanning a primary key can be up
            to 7x faster than scanning a secondary key + read the row data trough the
            primary key.

            optimizer-adjust_secondary_key_costs is added to provide 2 small
            adjustments to the 10.x optimizer cost model. This can be used in the
            case where the optimizer wrongly uses a secondary key instead of a
            clustered primary key.

            The different values for the new variable:

            optimizer_adjust_secondary_key_costs=0 (default)
            - No changes to current model

            optimizer_adjust_secondary_key_costs=1
            - Ensure that the cost of of secondary indexes has a cost of at
              least 5x times the cost of a primary key.
              This disables part of the worst_seek optimization described below.

            optimizer_adjust_secondary_key_costs=2
            - Disable "worst_seek optimization and adjust filter cost slightly
              (add cost of 1 if filter is used).
            ralf.gebhardt Ralf Gebhardt made changes -
            Labels not
            serg Sergei Golubchik made changes -
            Fix Version/s 10.6.17 [ 29518 ]
            Fix Version/s 10.6 [ 24028 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.11.7 [ 29519 ]
            Fix Version/s 11.0.5 [ 29520 ]
            Fix Version/s 11.1.4 [ 29024 ]
            Fix Version/s 11.2.3 [ 29521 ]
            shawn2016 Shawn Yan made changes -
            psergei Sergei Petrunia made changes -
            psergei Sergei Petrunia made changes -

            People

              monty Michael Widenius
              monty Michael Widenius
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.