database table structure:
Insert the SQL statement:
<InsertId="Insert"ParameterType="com. Structure "> INSERT intoSTRUCTURE (ID, structurename, parentid, Structuretype, description, DeptID, Propertycompanyid, Sort, Communityid)VALUES(#{id,jdbctype=VARCHAR}, #{structurename,jdbctype=VARCHAR}, #{parentid,jdbctype=VARCHAR}, #{structuretype,jdbctype=NUMERIC}, #{description,jdbctype=VARCHAR}, #{deptid,jdbctype=VARCHAR}, #{propertycompanyid,jdbctype=VARCHAR}, #{sort,jdbctype=VARCHAR}, #{communityid,jdbctype=VARCHAR}) </Insert>
BULK INSERT SQL statements:
<InsertId="Insertbatch" ParameterType="Java.util.List"> BEGIN <foreach Collection="List" item="Item"Index="Index"Separator=";"> INSERT intoSTRUCTURE (ID, structurename, parentid, Structuretype, Description, DeptID, Propertycompanyid, Sort, Communityid) VALUES(#{item.id,jdbctype=VARCHAR}, #{item.structurename,jdbctype=VARCHAR}, #{item.parentid,jdbctype=VARCHAR}, #{item.structuretype,jdbctype=NUMERIC}, #{item.description,jdbctype=VARCHAR}, #{item.deptid,jdbctype=VARCHAR}, #{item.propertycompanyid,jdbctype=VARCHAR}, #{item.sort,jdbctype=VARCHAR}, #{item.communityid,jdbctype=VARCHAR}) </Foreach> ;END ; </Insert>
Performance Test Results:
| Order of magnitude |
Bulk Insert time-consuming (ms) |
Time-to-insert (MS) |
| 10 |
50 |
68 |
| 100 |
197 |
257 |
| 1600 |
1671 |
33384 |
I had no idea that the magnitude of thousand would have been such a huge time-consuming difference.
Do not know whether to write, and the impact of the database type, temporarily make a record for their own reference.
Performance comparison of inserting data into Oracle based on MyBatis