4

I am trying to determine if I am going to see a performance impact. I have a view that can possibly return thousands of results but only displays 50 per page. Each node in the result determines it's proximity to the current user using geofield. I want to know if it's going to try and do it for every node in the result, or just the ones in the current page.

So, does Drupal load all of the nodes in the results or just the ones in the current page?

  • 1
    Great question, though I think the true answer is going to have more to do with how the DB performs the query internally when limits are applied. A LIMITed query will inevitably be faster than one with no LIMIT, but overall performance will also inevitably decrease as the number of nodes increases. I would hope that the DB engine is smart enough to stop querying for further records once the LIMIT has been reached, as opposed to querying every possible record then returning a filtered sub-section. But I have no idea :) – Clive Jul 2 '13 at 17:16
  • I've added the mysql tag as a very knowledgable DB admin visits the site quite regularly; hopefully he'll see this and help shed some light – Clive Jul 2 '13 at 17:18
  • One more comment on this: of course there's a db-side savings to limiting the query, but there are savings on the Drupal side too, since Drupal also wouldn't be running the additional processing on the Drupal side to do things like access checks, pre-processing and other display-related functions for the records that aren't returned. I should add some of this to my answer probably. I just mentioned that the specified number records are returned, but perhaps should have gone into more details about what that MEANS. – Boriana Ditcheva Jul 2 '13 at 17:28
  • Also keep in mind that Field Storage really complicates this. – mpdonadio Jul 2 '13 at 17:49
4

When you display a certain number of records per page it does not load and hide the extra records, it simply never pulls them from the database. So you'd certainly be helping performance by limiting the number that are displayed per page.

In fact, if you look at the SQL query generated by the view, it'll say the following if you're showing 20 items per page, for example:

...
LIMIT 20 OFFSET 0
...

====================== EDIT ====================

What this means for performance

As @Clive and I were discussing above in the comments, A LIMITed query will inevitably be faster than one with no LIMIT, but overall performance will also inevitably decrease as the number of nodes you are searching through increases.

Limiting the number of returned records has performance savings on the Drupal side too, though. That's because Drupal wouldn't be running the additional processing on the Drupal side to do things like access checks, pre-processing and other display-related functions for the records that aren't returned by the query.

==============================================

p.s. You can configure whether you want Views to show you the sql query it's generating by going to /admin/structure/views/settings and checking the 'Show the SQL query' checkbox in the 'Live Preview Settings' section.

  • what happen if ajaxs enabled for pager – Bala Jul 2 '13 at 18:34
  • 3
    Same - it looks like with ajax enabled for pager, it still limits the query to the specified number. – Boriana Ditcheva Jul 2 '13 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.