0

I've about 400k data and maybe more (in sql format) and going to insert it to mysql database. which one have better performance, to write the sql command in the sql file to insert the data :

  1. repeat this command for each data till 400k

    INSERT INTO table (col1, col2, coln) VALUES (val1, val2, valn);

  2. write INSERT command at first and then write the 400k data in the next VALUE statement

    INSERT INTO table (col1, col2, coln) VALUES (val1, val2, valn), (val1, val2, valn), (val1, val2, valn), ..... till the 400k data

  3. repeat this command like no.2 but only for maybe each 100 data

    INSERT INTO table (col1, col2, coln) VALUES (val1, val2, valn), (val1, val2, valn), (val1, val2, valn), ..... [till 100 data]
    INSERT INTO table (col1, col2, coln) VALUES (val1, val2, valn), (val1, val2, valn), (val1, val2, valn), ..... [till the next 100 data]

  4. or maybe there are another good options?

Ajay Kadyan
  • 1,081
  • 2
  • 13
  • 36
spondbob
  • 1,523
  • 2
  • 17
  • 34

1 Answers1

0

You can use first or second variant, the second one may be faster. If you choose second variant and statement length more then maximum allowed packet size (MySQL variable), then apply third variant - split INSERT statements into some small statements.

Devart
  • 119,203
  • 23
  • 166
  • 186