Problem of repetition

Recently, I was doing a synchronization of users and departments of other data sources, and batch insertion adopted the saveBatch method provided by MybatisPlus, but the speed was found to be very slow in the test

After looking through the source code, I found the following information:

MybatisPlus is also inserted repeatedly during batch insertion. Each time, it will judge whether the variable I reaches the threshold. If so, this batch of data will be refreshed to the database

The solution

Add rewriteBatchedStatements=true to jdbcUrl to make multiple batches commit in the same batch

The principle of

For details, see mysql Official Documentation

  • Documents screenshots