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

Port MySQL 5.7 select count() optimization

Details

    Description

      Current handler::records() is not fully usable as InnoDB could roll back the statement on some cases and you may not continue after that, it should be int records(ha_rows *n_rows) and server should check as these errors will abort the current query:
      case HA_ERR_LOCK_DEADLOCK:
      case HA_ERR_LOCK_TABLE_FULL:
      case HA_ERR_LOCK_WAIT_TIMEOUT:
      case HA_ERR_QUERY_INTERRUPTED:

      see commit 40ec5373c0 on 5.7

      Attachments

        Issue Links

          Activity

            jplindst Jan Lindström (Inactive) created issue -
            serg Sergei Golubchik made changes -
            Field Original Value New Value
            Description Current handler::records() is not fully usable as InnoDB could roll back the statement on some cases and you may not continue after that, it should be int records(ha_rows *n_rows) and server should check as these errors will abort the current query:
                 case HA_ERR_LOCK_DEADLOCK:
                 case HA_ERR_LOCK_TABLE_FULL:
                 case HA_ERR_LOCK_WAIT_TIMEOUT:
                 case HA_ERR_QUERY_INTERRUPTED:

            see commit 40ec5373c044547a66d5456b15d61553de8f3401 on 5.7
            Current handler::records() is not fully usable as InnoDB could roll back the statement on some cases and you may not continue after that, it should be int records(ha_rows *n_rows) and server should check as these errors will abort the current query:
                 case HA_ERR_LOCK_DEADLOCK:
                 case HA_ERR_LOCK_TABLE_FULL:
                 case HA_ERR_LOCK_WAIT_TIMEOUT:
                 case HA_ERR_QUERY_INTERRUPTED:

            see commit [40ec5373c0|https://github.com/mysql/mysql-server/commit/40ec5373c0] on 5.7
            serg Sergei Golubchik made changes -
            Issue Type Task [ 3 ] Bug [ 1 ]
            serg Sergei Golubchik made changes -
            Affects Version/s 10.2.2 [ 22013 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Petrunia [ psergey ]
            elenst Elena Stepanova made changes -
            Assignee Sergei Petrunia [ psergey ]

            Oracle removed this in MySQL 5.7.18, because it is hard-wired to use the clustered index.
            Sometimes using a secondary index could be a bad idea, because we do not have a hidden DB_TRX_ID column in the secondary indexes. For delete-marked records or for secondary index pages where PAGE_MAX_TRX_ID is too new, a lookup for a matching clustered index record must be performed (random lookups to the clustered index and optionally to undo log records). This is why it was hard-wired to use the clustered index in the first place.

            See also my old blog post that mentions InnoDB secondary indexes.

            marko Marko Mäkelä added a comment - Oracle removed this in MySQL 5.7.18 , because it is hard-wired to use the clustered index. Sometimes using a secondary index could be a bad idea, because we do not have a hidden DB_TRX_ID column in the secondary indexes. For delete-marked records or for secondary index pages where PAGE_MAX_TRX_ID is too new, a lookup for a matching clustered index record must be performed (random lookups to the clustered index and optionally to undo log records). This is why it was hard-wired to use the clustered index in the first place. See also my old blog post that mentions InnoDB secondary indexes.
            marko Marko Mäkelä made changes -
            Assignee Sergei Petrunia [ psergey ] Marko Mäkelä [ marko ]

            MDEV-11751 (Merge MySQL 5.7.18 to MariaDB 10.2) is removing the count optimization.

            marko Marko Mäkelä added a comment - MDEV-11751 (Merge MySQL 5.7.18 to MariaDB 10.2) is removing the count optimization.
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Fix Version/s N/A [ 14700 ]
            Fix Version/s 10.2 [ 14601 ]
            Resolution Won't Fix [ 2 ]
            Status Open [ 1 ] Closed [ 6 ]
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 75786 ] MariaDB v4 [ 150461 ]

            People

              marko Marko Mäkelä
              jplindst Jan Lindström (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.