Details

    Description

      The original description of this task read as follows:

      as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

      Normally one needs to create a table in InnoDB or XtraDB and then "export" it. But we could try to create an exported tablespace with a table not by actually exporting it but directly from the data, say, from XML or CSV.

      In the end, we decided to optimize the INSERT code path inside InnoDB. There are many different InnoDB ROW_FORMAT, and we do not have instant import until MDEV-11658 gets some thought. Besides, if we make INSERT faster, also some normal workloads will benefit.

      We implement an idea that was suggested by monty in October 2017: When InnoDB is inserting into an empty table or partition, we can write a single undo log record TRX_UNDO_EMPTY to cover the operation. ROLLBACK would clear the table when undoing this record.

      For this to work, the insert into an empty table or partition must be covered by an exclusive table lock that will be held until the transaction has been committed or rolled back, or until a partial rollback that affects the INSERT operation (so that the table is empty again).

      Concurrent non-locking reads must be adjusted: If the read view was created before the INSERT into an empty table was committed, then we must continue to imagine that the table is empty, and not try to read any records. If the read view was created after the COMMIT of the INSERT, then all records must be visible normally.

      This special handling only applies to the very first INSERT statement of a transaction for the empty table or partition. If a subsequent statement in the transaction is modifying the initially empty table again, we must enable row-level undo logging, so that we will be able to roll back to the start of the statement in case of an error (such as duplicate key).

      INSERT IGNORE will continue to use row-level logging and locking, because implementing it would require the ability to roll back the latest row, while our table-level logging only allows the entire statement to be rolled back.

      Future work:

      • MDEV-24621 will make such INSERT even faster, by sorting the records for each index separately and by building indexes one page at a time.
      • MDEV-24622 will enable this feature on replicas (slaves).
      • MDEV-24623 will enable this feature on Galera cluster.

      Attachments

        Issue Links

          Activity

            serg Sergei Golubchik created issue -
            serg Sergei Golubchik made changes -
            Field Original Value New Value
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Description as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

            1. analyze innodb tablespace format
            as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

            InnoDB and Percona Server/XtraDB support exportable tablespaces. Wee could try to create an exported tablespace with a table not by actually exporting it but directly from the data, say, from XML or CSV.
            serg Sergei Golubchik made changes -
            Description as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

            InnoDB and Percona Server/XtraDB support exportable tablespaces. Wee could try to create an exported tablespace with a table not by actually exporting it but directly from the data, say, from XML or CSV.
            as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

            Normally one needs to create a table in InnoDB or XtraDB and then "export" it. But we could try to create an exported tablespace with a table not by actually exporting it but directly from the data, say, from XML or CSV.
            serg Sergei Golubchik made changes -
            Fix Version/s 10.1.0 [ 12200 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Assignee Jan Lindström [ jplindst ]
            serg Sergei Golubchik made changes -
            Assignee Jan Lindström [ jplindst ]
            serg Sergei Golubchik made changes -
            Labels innodb
            dbart Daniel Bartholomew made changes -
            Priority Major [ 3 ] Minor [ 4 ]
            serg Sergei Golubchik made changes -
            Workflow defaullt [ 14115 ] MariaDB v2 [ 42608 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.1 [ 16100 ]
            Fix Version/s 10.1.0 [ 12200 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Workflow MariaDB v2 [ 42608 ] MariaDB v3 [ 61584 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.1 [ 16100 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Assignee Thirunarayanan Balathandayuthapani [ thiru ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s N/A [ 14700 ]
            marko Marko Mäkelä made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s N/A [ 14700 ]
            thiru Thirunarayanan Balathandayuthapani made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            thiru Thirunarayanan Balathandayuthapani made changes -
            marko Marko Mäkelä made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Assignee Thirunarayanan Balathandayuthapani [ thiru ] Marko Mäkelä [ marko ]
            julien.fritsch Julien Fritsch made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            Component/s Storage Engine - InnoDB [ 10129 ]
            Description as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

            Normally one needs to create a table in InnoDB or XtraDB and then "export" it. But we could try to create an exported tablespace with a table not by actually exporting it but directly from the data, say, from XML or CSV.
            The original description of this task read as follows:
            {quote}
            as a solution for bulk-inserting huge amount of data into innodb, we consider an utility that creates exported innodb tablespaces.

            Normally one needs to create a table in InnoDB or XtraDB and then "export" it. But we could try to create an exported tablespace with a table not by actually exporting it but directly from the data, say, from XML or CSV.
            {quote}
            In the end, we decided to optimize the {{INSERT}} code path inside InnoDB. There are many different InnoDB {{ROW_FORMAT}}, and we do not have instant import until MDEV-11658 gets some thought. Besides, if we make {{INSERT}} faster, also some normal workloads will benefit.

            We implement an idea that was suggested by [~monty] in October 2017: When InnoDB is inserting into an empty table or partition, we can write a single undo log record {{TRX_UNDO_EMPTY}} to cover the operation. {{ROLLBACK}} would clear the table when undoing this record.

            For this to work, the insert into an empty table or partition must be covered by an *exclusive table lock* that will be held until the transaction has been committed or rolled back, or until a partial rollback that affects the {{INSERT}} operation (so that the table is empty again).

            Concurrent non-locking reads must be adjusted: If the read view was created before the {{INSERT}} into an empty table was committed, then we must continue to imagine that the table is empty, and not try to read any records. If the read view was created after the {{COMMIT}} of the {{INSERT}}, then all records must be visible normally.

            This special handling only applies to the very first {{INSERT}} statement of a transaction for the empty table or partition. If a subsequent statement in the transaction is modifying the initially empty table again, we must enable row-level undo logging, so that we will be able to roll back to the start of the statement in case of an error (such as duplicate key).

            {{INSERT IGNORE}} will continue to use row-level logging and locking, because implementing it would require the ability to roll back the latest row, while our table-level logging only allows the entire statement to be rolled back.

            Future work:
            * MDEV-24621 will make such {{INSERT}} even faster, by sorting the records for each index separately and by building indexes one page at a time.
            * MDEV-24622 will enable this feature on replicas (slaves).
            * MDEV-24623 will enable this feature on Galera cluster.
            Labels innodb performance
            marko Marko Mäkelä made changes -
            issue.field.resolutiondate 2021-01-25 16:44:17.0 2021-01-25 16:44:17.987
            marko Marko Mäkelä made changes -
            Fix Version/s 10.6.0 [ 24431 ]
            Fix Version/s 10.6 [ 24028 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            elenst Elena Stepanova made changes -
            marko Marko Mäkelä made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            marko Marko Mäkelä made changes -
            danblack Daniel Black made changes -
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            marko Marko Mäkelä made changes -
            Roel Roel Van de Paar made changes -
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 61584 ] MariaDB v4 [ 131975 ]
            Roel Roel Van de Paar made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            bar Alexander Barkov made changes -
            marko Marko Mäkelä made changes -
            Roel Roel Van de Paar made changes -
            ycp Yuchen Pei made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 104989
            marko Marko Mäkelä made changes -

            People

              marko Marko Mäkelä
              serg Sergei Golubchik
              Votes:
              10 Vote for this issue
              Watchers:
              22 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.