The above link, insert line 1 million takes 24 seconds, governor of very short
Can say very slow
As my test program, is the above links to insert 100000 rows, President of 10 a few times
According to the number of bytes to calculate, I INSERT more bytes on such as link
But I only took 1 seconds in notebooks,
What reason is this? Why is my test so fast?
Long SSS=System. CurrentTimeMillis ();
String STRSQL="insert into the test values (?,?,?,?,? ,? ,? ,?) ";
PreparedStatement prest=conn. PrepareStatement (STRSQL, ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_READ_ONLY);
For (int I=1; I & lt;=100000; I++)
{
Prest. SetString (1, "1001100" + I);
Prest. SetString (2, "hello hello" + I);
Prest. SetString (3, "XXXX" + I);
Prest. SetString (4, "hello, hello hello hello hello hello hello hello hello hello hello hello" + I);
Prest. The addBatch ();
}
Prest. ExecuteBatch ();
Long eee=System. CurrentTimeMillis () - SSS;
System. The out. Println (" \ nbatch insert Time spend: "+ eee);
In addition to the bulk insert, and more efficient to write code? Mybatis?
Seemingly complicated
thank you
CodePudding user response:
Insert into table1 (column1, column2,... ) values(a1, a2,... ),
(b1, b2,... ),
(c1, c2,... )
Pay attention to the length of the SQL statement
CodePudding user response: