NYCPHP Meetup

NYPHP.org

[nycphp-talk] slow php

Rolan Yang rolan at omnistep.com
Fri Feb 13 16:16:50 EST 2009


Nicholas Hart wrote:
> I have a php 'cron job' script which is inserting some records.  It 
> uses arrays to store 12 field records along with several nested loops 
> in which it tests various currency values from a separate 4 field 
> table and sorts them to get the lowest one for insert into a new 4 
> field table record.  It has about 640,000 Product records per 4 
> Customers or apporx. 2.4 million records to insert.  It takes several 
> hours+ to complete and I am hoping there is a way to speed it up. 
>

If you can get away with it, you might try dumping the data to a csv 
file and using a "load data infile" within mysql to import the whole 
batch of data at once. Another thing that might be slowing down your 
inserts are mysql indexes. If you can disable your indexes, import the 
data, then re-index afterwards, that should speed up the import.

~Rolan



More information about the talk mailing list