Skip to content

Commit

Permalink
Document why disabling autocommit is important during writes
Browse files Browse the repository at this point in the history
  • Loading branch information
hashhar committed Jul 15, 2021
1 parent 2c2b13f commit 543cd1f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public JdbcPageSink(ConnectorSession session, JdbcOutputTableHandle handle, Jdbc
}

try {
// According to JDBC javaodcs "If a connection is in auto-commit mode, then all its SQL statements will be
// executed and committed as individual transactions." Notably MySQL and SQL Server respect this which
// leads to multiple commits when we close the connection leading to slow performance. Explicit commits
// where needed ensure that all of the submitted statements are committed as a single transaction and
// performs better.
connection.setAutoCommit(false);
}
catch (SQLException e) {
Expand Down

0 comments on commit 543cd1f

Please sign in to comment.