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

PERFORMANCE issue with INSERT and out of order PKs

    XMLWordPrintable

Details

    Description

      If you have a medium size table, say 100,000 rows, and you issue a single INSERT statement with a VALUES clause containing 5,000 or so short rows (3 columns of bigint) and the primary keys are in ascending order it might take X time to insert. If the keys are out of order, it might take 10x+ the time to insert.

      However, if you insert out of order keys using INSERT INTO t1 (x,y,z) SELECT a,b,c FROM t2 you can process 100,000 rows with out of order keys in <x time (more than 10x as fast).

      It seems that when inserting with INSERT INTO t1 (x,y,z) SELECT a,b,c FROM t2 all the unique checks and index building is done once where as if you insert multiple rows in a single INSERT INTO t1 (x,y,z) VALUES (1,2,3), (7,8,9), (4,5,6) the rows are processed MUCH more slowly.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rdyas Robert Dyas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.