Learn something new everyday...
Today it was with PDO and memory usage.
When doing large data inserts with transactions, you should
always do your query preparation outside of your loop.
$p = $datasource->prepare('INSERT a SET b = :c');
If the query prepare is moved into the loop, an exorbitant
amount of memory and time is consumed parsing the query every
iteration. For a million inserts, this can result in
exceeding allowed memory usage.