Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1214

Batched INSERT ... ON DUPLICATE KEY UPDATE statements are no longer execute with `executeBatchBulk`

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • 3.4.0, 3.4.1, 3.5.0
    • N/A
    • batch, performance
    • None

    Description

      Batched INSERT ... ON DUPLICATE KEY UPDATE statements are no longer execute with `executeBatchBulk`:

      String insertQuery = """
      	INSERT INTO
      		test.table
      		(id, text)
      	VALUES
      		(?, ?)
      	ON DUPLICATE KEY UPDATE
      		text = VALUES(text)
      	""";
       
      PreparedStatement stmt = conn.prepareStatement(insertQuery);
       
      for (int i = 0; i < 20; i++) {
      	stmt.setInteger(1, i);
      	stmt.setString(2, "text");
      	stmt.addBatch();
      }
       
      stmt.executeBatch();
      

      With version 3.3.3, this sample statement was executed with `executeBatchBulk`. Since 3.4.0, `executeBatchBulk` will not be used for INSERT ... ON DUPLICATE KEY UPDATE anymore:

          ...
          boolean isNormalInsert = clientParser.isInsert() && !clientParser.isInsertDuplicate();
       
          if (con.getContext().hasServerCapability(STMT_BULK_OPERATIONS)
              && ((isNormalInsert && (conf.useBulkStmts() || conf.useBulkStmtsForInserts()))
                  || (!clientParser.isInsert() && conf.useBulkStmts()))
              ...
      

      https://github.com/mariadb-corporation/mariadb-connector-j/blob/2eacf8a0b88f6316a412e552b7fc3edd3671bbba/src/main/java/org/mariadb/jdbc/ClientPreparedStatement.java#L126

      Is there a parameter I haven't found yet to execute these kinds of statements as bulk?

      Attachments

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              Christopher Christopher Wilke
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.