Answer the question
In order to leave comments, you need to log in
How to copy millions of rows from one table to another?
There is a task on the sale, to copy millions of rows from one table to another, checking whether there is such a record when inserting. Performance is very important so that the query does not run for several hours. The structure of the tables, the set of fields are different.
The first thing that comes to mind is:
1) Write a doctrine migration, most likely it will be very slow
2) Write a SQL query that can be run in the console, which is fraught with long execution, especially if there are subqueries
3) Limit the number of records processed at a time, add a limit or batch processing
4) Use some built-in copying, backup tools.
Answer the question
In order to leave comments, you need to log in
INSERT INTO ...
SELECT ...
WHERE ...
LIMIT ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question