I did the following experiment:
- I inserted 100.000 rows in a database table called "event_history" by calling the function "query_write" 100.000 times. The total execution time for this operation is of 217.99 seconds.
- I copied the data from the above table (event_history) to another table (event_shadow) using an INSERT-SELECT operation, like this one:
Code:
INSERT INTO event_shadow (user_id, event_day, event_time, event_type, multiplication_factor, vp, red_points, blue_points, green_points, yellow_points, black_points)
SELECT user_id, event_day, event_time, event_type, multiplication_factor, vp, red_points, blue_points, green_points, yellow_points, black_points
FROM event_history;
Here it comes the big surprise: the second operation is finished in 2.15 seconds - that is about
100 times faster. What is the explanation for this ? Both operations perform
100.000 inserts !
Regards,
Razvan