When we are doing an insert of huge no.of rows into an SQL table ,Normally we will try to write separate insert quries this may lead us to a long duration of execution time and we can increase the speed of executing SQL quries by adding all the rows into a single insert query.
NORMAL CASE:
eg:INSERT INTO tbl_name(field1,field2,…) values(value1,value2,..); INSERT INTO tbl_name(field1,field2,…) values(value1,value2,..); INSERT INTO tbl_name(field1,field2,…) values(value1,value2,..);
We can decrease the execution time by adding all these rows into a single INSERT query like below,
INSERT INTO tbl_name(field1,field2,…) values(value1,value2,..),values(value1,value2,..),values(value1,value2,..),….;
This is useful when we are trying to insert about 10k of rows into a table at a time. For me normally it takes 1min 15 sec to insert 10k of rows but by using this tip it takes only 10 sec to insert 10k of rows.
i have tried this when i did excel and csv import feature. For excel it took around 20 sec and for csv it took 10 sec of execution time for inseting 10k of rows.
Reagards,
sirin k