$data['sites'] = Model_Site::find('all', array('order_by' => array('site' => 'asc')));(directly from scaffolding code) to get the data. The call to this appears to be pretty instant, so my guess is that this is lazily loaded. The problem is, I can't quite work out where it's finally loaded. It seems to be before I personally access it (I can comment out all lines in my view (thus never using the data) and it still lags) but the request building and sending process is a weird one. It seems that Request->execute()->response() only seems to run the controller action and lazily load the view when a __toString is called on the resulting Response object's body. (Maybe. This is where I got lost.) My question here, then, really, is what is the flow here? Also, while I know getting everything from the DB and not using pagination is a bad idea, even if I didn't code it as a table in HTML (but instead as a JS object) it'd still lag. The only way it wouldn't lag would be to only return a few at a time, and use AJAX in the autocomplete/filter field, but I like the idea of the instant updates on the page so would rather not go down the AJAX route. So let's ignore my possibly bad design choice, and I'm 99.999% certain it's the DB query but only when loading the view HTML that's the issue (like I said I put in a bunch of Profiler:mark calls even in the index.php file and I noticed the lag right before the bit where it adds the stats (presumably on the call to $response->body() within the call that sets the $response->body(), and if I comment that out, the lag suddenly happens just before $response->send(). But I then gave up working out what happens with this as (as I said above) it appears to use the magic __toString method on at least one of the classes here, and magic methods make it very difficult to follow execution flow! So can someone who knows the internals let me know whether the lag is likely to be the lazy loading of the Models from the DB call (1000ish entries from DB although not an absolute tonne of data) , and if so, what I can do to mitigate that (assuming I can't paginate for whatever reason and I need all 1000 rows. As an addendum, I did try adding a limit to that ORM::find call to 500 and the lag pretty much halve, and then down to 20 and it was unnoticeable, so I assume it is the sheer amount of rows I'm fetching. In fact I've just added a __construct method to my model (with a call to parent::_construct obviously and a Profiler::mark) and I see that that's not the source of the lag either (although is the source of about a second lag in a different bit of the code (Request::execute start and Request::execute end)). Is there something I'm missing here? It looks like it has to be something internal as it's not model hydration, nor is it the big dirty loop in the view (as I can blank out the view and still get the lag) but does appear to rely on the amount of data I'm passing around.
... Fuel\Core\Request::execute Start 22.098 ms Fuel\Core\Request::execute End 1.140 s Template start 1.141 s About to echo $content 1.157 s View start 5.433 s View end 5.433 s Done echoing $content 5.433 s Template end 5.433 s End of Fuel Execution 5.435 s
It looks like you're new here. If you want to get involved, click one of these buttons!