I've created a stored procedure. I fetch cursor with huge amount of data(around 1L rows). After that I call another procedure in it to do all calculations related to needed data. I create temporary table and try to insert this calculated data in it. But it takes too long about 9.5 mins. I want to know how to insert bulk data by using least "INSERT" queries as 1L insert queries cause poorest performance. Can anyone help me??
Asked
Active
Viewed 1.3k times
3 Answers
8
You can use the following SQL statement for bulk insert:
INSERT INTO TABLE_A (A, B, C, D) VALUES
(1,1,1,1),
(2,2,2,2),
(3,3,3,3),
(4,4,4,4);

Andrew Landsverk
- 673
- 7
- 17
2
Your question is a bit vague but you can BULK load data into mysql using
load data infile...
Check the following links:
If you need to process the data during the load it might be better to first bulk load the data into a temporary table then run some stored procedures against it which process and populate your main tables.
Hope this helps.
0
also you can insert record to in-memory table.after complete inserting to in-memory table following code for insert many rows from in-memory table.
INSERT INTO TABLE_A (A, B, C, D)
SELECT A,B,C,D FROM INMEMORY_TABLE
DELETE FROM INMEMORY_TABLE

MajidTaheri
- 3,813
- 6
- 28
- 46