There might be couple nuances to be considered carefully:
-
For
SELECT *I recommend narrowing the selection to only the specific columns required for the task. This reduces the size of each row object and further optimizes the migration's performance -
Using fetchAll() is memory-intensive as it attempts to load the entire result set into an array. I would refactor this to iterate through the rows one-by-one to keep the memory footprint low, like this:
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
// manipulate the data here
}