A lot of the time I don’t need fully completely activerecord objects.
f.i. when showing a list of records I don't need the relations with associated tables, rollback values, etc. because nothing will change to the objects.
There will not be a save(), no validation is needed.
So I was wondering: isn’t it possible, to get some kind of 'light', read only objects from a find() ?
I'm asking because a website I made using Akelos is becoming terribly slow.. The public pages are more or less bearable, but once users are logged in there are some pages who make calculations using values from different tables. Some take up to 20 seconds to load.
The website is on a shared server of course. But even on my local machine some pages take several seconds.
Thijs, as long as you don't use associations, they should not be loaded.
A lightweight version of the Active Record, might be possible by magically load functionality such as validations as required. That will come once we drop support for PHP4.
As a quick solution, I'd suggest to use caching at different levels. Last week of September Arno will merge his caching branch into the trunk, which brings really easy caching to Akelos.
If caching is not possible, you might find useful the phpAdoDb handler to execute queries without involving Active Record instances.
If caching is not possible, you might find useful the phpAdoDb handler to execute queries without involving Active Record instances.
Yes, I’ve seen it here. Didn’t use that though, but in some places I do direct queries using mysql_query().
Harder to debug, but I suppose they are faster.
I’ll look into the caching system when the branch is added. Thanks.
Some other thing that might help:
Is it possible to select the fields a find() should return, so it doesn’t do a 'SELECT * ...' all the time?
I found in the wiki that you can use 'select' to pick the needed fields when defining an association, but is possible in a find() ?
Is it possible to select the fields a find() should return, so it doesn’t do a 'SELECT * ...' all the time?
Should be simple by adding the columns option to the finder and modifying AkActiveRecord::constructFinderSql, but it might be a disaster on 90% of the cases when users modify the records as it will destroy unloaded columns. I don't think * is the bottleneck in the AR, but the memory it takes for each large model object.
1 to 4 of 4