[Mybatis beginner’s lecture from 0 to 90%] 11: Mybatis batch insertion batchInsert

CSDN achieves 100 million technical people

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

Guess you like

Origin blog.csdn.net/scm_2008/article/details/134129421