Article directory
Preface
In actual development, we often needto batch insert a large amount of data into the database, and MyBatis also provides support for batch insertion, which can Greatly improve insertion efficiency.
What I want to share today is what is commonly used in workUsing foreach tag in MapperThe way of inserting data in batches is better than calling Mapper cyclically inJava codeSingle insertPerformance requiredHigh performance!
foreach batch insert
MyBatis uses foreach batch insertion is a commonOptimize database write performancemethod, which can insert multiple statements intomerge is a batch insert statement, thereby reducing the number of database connections and network transmission time, improving writing performance!
Mapper:
void batchInsert