You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In SpringTransactionManager, any time Transaction.prepareBatchStatement is called, a new PreparedStatement is opened. In other implementations, the statements are cached in the transaction and re-used for the same SQL statement.
Harmless functionally, but affects performance.
The text was updated successfully, but these errors were encountered:
badgerwithagun
changed the title
SpringTransactionManager does not re-use insert PreparedStatements
SpringTransactionManager does not cache insert PreparedStatements
Jun 4, 2020
In most cases, the JDBC driver (or the database itself) will implement prepared statement caching, no? I am not sure you really need to do anything here.
This isn't really about statement caching as such. The trick that Transaction.prepareBatchStatement pulls is that any statement opened this way gets executeBatch called on it automatically at the end of the transaction, so if you write a 100 outbox records in one transaction they all get pushed out in one go in the same batch.
Because SpringTransactionManager isn't correctly caching, each insert is made in a separate request to the DB, which is indeed costly if you're doing a lot of "fan out" type behaviour (I am also planning on "fan in" capability...)
In
SpringTransactionManager
, any timeTransaction.prepareBatchStatement
is called, a newPreparedStatement
is opened. In other implementations, the statements are cached in the transaction and re-used for the same SQL statement.Harmless functionally, but affects performance.
The text was updated successfully, but these errors were encountered: