That's a lot of items to be putting into an array and probably a lot of memory being used. If you are accessing it incrementally, why not write everything to a flat file and access it a few lines at a time? I may be misunderstanding what you mean by incrementally, since you mention you are using keys.
Chunking the array is still using the same amount of memory, probably more since you now have multiple arrays to track. Can you write out to a file the chunks you are not using? You may need to serialize the array before writing it out. And don't forget to unset the array after writing it out to free up the memory.
Last suggestion. Can you put the data into a HEAP or temporary table in MySQL?



On May 11, 2004, at 8:18 AM, Anna wrote:


Hi There,

What techniques are there to optimise the use of very large arrays? I have
an array of over 380K keys and values that is being processed incrementally,
however the longer it runs the more time is seems to be taking - an array of
100k items is taking 1 hour to process, and array of 400k items is taking 9
hours to process.


I'm chunking up the array into smaller arrays, but that doesn't seem to be
making much difference.


Thanks
Anna

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to