Not sure if this is the right topic. But I'm having problems with inserting allot of data at once.
I have around 100k rates from a csv file which I need to add to the database which looks more or less like this:
// loop rates
foreach ($supplierInfo['rates'] as $rateArray ){
// save rate to DB
$objRate = $modx->newObject('sfVehicleRate');
$objRate->fromArray($rateArray);
$objRate->save();
}
<object class="sfVehicleRate" table="vehicle_rates" extends="xPDOSimpleObject">
<field key="vehicleid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
<field key="periodid" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
<field key="price" dbtype="float" precision="10" attributes="unsigned" phptype="float" null="true" default="0" index="index" />
<field key="location" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="Vehicle" class="sfVehicle" local="vehicleid" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Period" class="sfRatePeriod" local="periodid" foreign="id" cardinality="one" owner="foreign" />
</object>
This all work fine on my development machine as i have "allot of memory", unfortunately on the clients hosting environment i reach the memory limit just after a few hundert inserts.
Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /core/xpdo/om/xpdoobject.class.php on line 1239
I could probably run a cron job with some perl/shell script but was wondering, what exactly I'm doing wrong, or is there a more efficient way to do so?
Ok 20MB is not that much but somehow it should be possible ?
Perhaps by adding them via a xpdo->query directly?
Thanks for any feedback as i really love MODX and XPDO.