Tom, findBySql instantiates results which obviously takes CPU time and memory.
But you probably don't want keep 9000 models loaded in memory.
FYI Ak::db returns an ADODB connection so you can do something like:
$conn = Ak::db();
$recordSet = &$conn->Execute('select * from products');
$ProductInstance =& new Product();
while (!$recordSet->EOF) {
$Product = $ProductInstance->instantiate($ProductInstance->getOnlyAvailableAtrributes($recordSet->fields), false);
// Do something with $Product
$recordSet->MoveNext();
}
Ok, this way it may save a lot of memory, but still the models get instantiated, right? Suppose that's what takes so much time.
However, I saved some seconds by just grabbing the fields from the recordSets, without instantiating AkActiveRecords:
$conn = Ak::db();
$recordSet = &$conn->Execute('select * from products');
$ProductInstance =& new Product();
while (!$recordSet->EOF) {
$this->my_products[] = $recordSet->fields;
$recordSet->MoveNext();
}
Also, I removed the 9000 calls to UrlHelper::url_for() in my view, creating the URLs manually. Not as beautiful, but faster.
It's feasible now with the 9000 records, but it still takes a couple of seconds. I better display some kind of progress indicator in my view while the result is loading...
Thanks!
Tom
1 to 5 of 5