Inserting massive amount of records with PHP
I'm building a mailing tool for a client of ours and need to send an email to all their client contacts (over 130 000 emails). This is the first time i need to insert such a huge amount of records to the mailqueue table.
Previously i inserted them one by one with an insert query. After a while that wasn't performant enough while inserting 1000+ records so i modified the query to insert multiple records at once [insert into table (field, ...) values (val, ...), (val, ...), (val, ...), ...]
I was already running into php memory limit problems when inserting the 1000+ records one by one. This is now solved by the above query but i'm afraid i'm going to run into memory limit problems again when inserting the 130 000 records.
Anyone has another solution how i can add 130 000 records to a database? Perhaps with sessions and a page that reloads itself???
Any idea's are welcome and will be considered