We have a program where we are trying to import Customers and Orders using php into Magento from a non-Magento system via csv files.
In a loop we call this function to get a customer model of previously imported customers so that we can attach the current order (from the csv file) to the correct customer:
$customers = Mage::getModel('customer/customer') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('old_customer_id', $data['SessionID']) ->load();
The load of the customer model happens fine, that is not the issue. Our previously imported customers are all there. The issue is that the customer model load above takes about one second each time it's called in the loop that reads the order records from a csv file, which is slow. But the second time we run the program, any customer that was loaded during a previous run loads very quickly, orders of magnitude faster.
Does Magento cache customers during a load() operation or index them or something that causes the second load to be much faster than the first?
If so, can we pre-cache or index customers by the attribute we are searching on 'SessionID' in order to make the customer model load faster?
There are about a million order records to process in the csv file so we need to get better performance to make this approach viable.