mysql - Executing multiple insert queries -
i insert 365 insert records, want know better.
1) inserting 1000 insert queries 1 one (for every record)
2) insert
insert table name ('field1', 'field2') values (value,value),(value,value),(value,value),(value,value)
i want second 1 perform faster , useful.
according mysql insert plan have following issues time spend on:
- connecting - sending query server - parsing query - inserting row (1 × size of row) - inserting indexes: (1 × number of indexes) - closing
due this, multiple insert more faster since produce connecting
, sending query server
, parsing query
, closing
overheads once. , shown in manual too:
- if inserting many rows same client @ same time, use insert statements multiple values lists insert several rows @ time. considerably faster (many times faster in cases) using separate single-row insert statements. if adding data nonempty table, can tune bulk_insert_buffer_size variable make data insertion faster. see section 5.1.4, “server system variables”.
Comments
Post a Comment