You can try calling set_time_limit()
repeatedly, for example after every row you insert. It resets the time limit each time you call it. If your server administrator has set up a global time limit this won't allow you to exceed that, however.
But inserting half a million rows one by one into an InnoDB table in MySQL is inherently slow because it needs to do an autocommit after every row.
If you do the insert in batches you'll gain a lot of speed. For example, your are probably doing something like this now:
INSERT INTO table (col1, col2, col3) VALUES (1, 'baker', 'charlie');
INSERT INTO table (col1, col2, col3) VALUES (2, 'delta', 'echo');
INSERT INTO table (col1, col2, col3) VALUES (3, 'foxtrot', 'golf');
INSERT INTO table (col1, col2, col3) VALUES (4, 'hotel', 'india');
INSERT INTO table (col1, col2, col3) VALUES (5, 'lima', 'mike');
Instead do this:
INSERT INTO table (col1, col2, col3) VALUES
(1, 'baker', 'charlie'),
(2, 'delta', 'echo'),
(3, 'foxtrot', 'golf'),
(4, 'hotel', 'india'),
(5, 'lima', 'mike');
That way you'll incur the commit overhead on MySQL for every five rows rather than for every one. Notice that you can put many rows into a single INSERT, not just five. MySQL's only limit on query length can be found with SHOW VARIABLES LIKE 'max_allowed_packet';
.
Of course this a little more complex to program, but it's much faster.