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

Performance regression in INSERT…SELECT due to unnecessarily making InnoDB log durable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Blocker
    • Resolution: Unresolved
    • 10.6.9, 10.6.18, 10.6.19, 10.6.20, 10.11.10
    • 10.6, 10.11, 11.4, 11.8

    Description

      Profiling shows the problem to be in the "Sending data" step:
      10.5: Duration: 0.00146 seconds
      10.6: Duration: 0.010226 seconds

      Queries such as this:

      INSERT IGNORE INTO LegArg ( LegHdl, ID, NumVal, StrVal ) 
      SELECT LegHdl,10005,19388,'gDRRVDkky9PfbYTAkmVzDNWPZyZM1S63qxivoXaMBK53FfcsxjKMl2yFBX6iyYjs' 
      FROM Leg 
      WHERE LHash=x'00013A942AE53E7279946CBC428FF7B815867A39'
      ;
      

      ...when executed several thousand times, as in normal ingest jobs, result in an overall execution time 3,750% slower on average in MariaDB 10.6 than 10.5. Here's some timing results:

      10.5.27:
       839KiB 0:00:00 [1.90MiB/s]
      real	0m0.586s
       
       839KiB 0:00:00 [1.77MiB/s]
      real	0m0.617s
       
       839KiB 0:00:00 [1.94MiB/s]
      real	0m0.566s
       
       839KiB 0:00:00 [2.02MiB/s]
      real	0m0.531s
       
      10.6.20:
       870KiB 0:00:19 [45.7KiB/s]
      real	0m20.167s
       
       870KiB 0:00:19 [45.6KiB/s]
      real	0m20.215s
       
       870KiB 0:00:17 [48.4KiB/s]
      real	0m19.096s
       
       870KiB 0:00:19 [45.6KiB/s]
      real	0m20.262s
      

      By contrast, separating the operation out so that SELECTS populate a temporary table and then the INSERT is done directly from the temporary table with no selective predicate results in comparable performance in 10.6.20:

      create temporary table tLegArg like LegArg;
      INSERT IGNORE INTO tLegArg ( LegHdl, ID, NumVal, StrVal ) SELECT `LegHdl`,10003,51944,NULL FROM `Leg` WHERE `LHash`=x'e5d701b83032f1dd2551e230adee7f0b5721d86b';
      INSERT IGNORE INTO LegArg select * from tLegArg;
       
       839KiB 0:00:00 [2.02MiB/s]
      real	0m0.557s
       
       839KiB 0:00:00 [1.98MiB/s]
      real	0m0.577s
       
       839KiB 0:00:00 [1.92MiB/s]
      real	0m0.577s
       
       839KiB 0:00:00 [2.02MiB/s]
      real	0m0.556s
      

      The problem appears in all minor releases of 10.6, and persists in 10.11.10. However, 11.4.4 is not affected by the regression.

      To reproduce see internal comments.

      Attachments

        1. 10.6.21.7z
          21 kB
        2. db-uk-server.cnf
          0.6 kB
        3. global_status_10.5.out
          14 kB
        4. global_status_10.6.out
          14 kB
        5. hdd_10.6_fsync.svg
          645 kB
        6. hdd_10.6_O_DIRECT.svg
          615 kB
        7. perf-10.5.svg
          386 kB
        8. perf-10.6.svg
          396 kB

        Issue Links

          Activity

            marko Marko Mäkelä added a comment - https://github.com/MariaDB/server/pull/3888
            monty Michael Widenius added a comment -

            This patch has two bug fixes. Both looks good and ok to push. However, I would suggest that we separate it into two commits to make future bisects easier.

            monty Michael Widenius added a comment - This patch has two bug fixes. Both looks good and ok to push. However, I would suggest that we separate it into two commits to make future bisects easier.
            monty Michael Widenius added a comment -

            reviewed

            monty Michael Widenius added a comment - reviewed
            axel Axel Schwenke added a comment -

            BTW, I discovered another oddity: the server status variables COM_{begin, commit, insert, select} and Handler_commit do not increase. The workload however contains 4000 INSERT ... SELECT statements and 8 BEGIN and COMMIT pairs.

            I think this also has to do with the "shortcut" evaluation of INSERT ... SELECT when both tables are InnoDB.

            This behavior is however the same for 10.5 and 10.6.

            axel Axel Schwenke added a comment - BTW, I discovered another oddity: the server status variables COM_{begin, commit, insert, select } and Handler_commit do not increase. The workload however contains 4000 INSERT ... SELECT statements and 8 BEGIN and COMMIT pairs. I think this also has to do with the "shortcut" evaluation of INSERT ... SELECT when both tables are InnoDB. This behavior is however the same for 10.5 and 10.6.
            marko Marko Mäkelä added a comment -

            monty, my fix is basically an improved fix of the recovery failure that prompted the filing of MDEV-25910, which consists of removing one call from a code path that may be executed outside ALTER TABLE…ALGORITHM=COPY and adding an equivalent invocation to the ALTER TABLE…ALGORITHM=COPY code path. I think that these changes logically belong together.

            marko Marko Mäkelä added a comment - monty , my fix is basically an improved fix of the recovery failure that prompted the filing of MDEV-25910 , which consists of removing one call from a code path that may be executed outside ALTER TABLE…ALGORITHM=COPY and adding an equivalent invocation to the ALTER TABLE…ALGORITHM=COPY code path. I think that these changes logically belong together.

            People

              serg Sergei Golubchik
              juan.vera Juan
              Votes:
              1 Vote for this issue
              Watchers:
              15 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.