Showing the "more" link conditionally requires views to do a count query in addition to the regular query. The count query is often extremely expensive.
I have two ideas for solutions:
- The current interface asks "Create more link" and "Always display more link". We could change those a bit to say "Create more link" and "Only display more link if there is more content" or similar. This idea is based on the claim is that most of the time people want to show the more link unconditionally. It's only useful for it to be conditional on sites with very little content. Given that it's more common to want it and that showing it conditionally is a potential performance issue it seems worth it to change the default.
- If a pager is not needed then the "more" link could simply query for "are there more items than the X shown here" and do a new query with a slightly longer limit. For example, if a block is showing 5 items, do a second query for the 6th item. If that query has data then show the more link. A query looking for the 6th record should be much faster than the query counting all data.
Comments
Comment #1
dawehner#1026014: Count queries run even if 'Always display more link' on
Regarding 2) There was a plan to integrate such a query plugin into views. Here it will help, too.
Comment #2
merlinofchaos commentedCommitted #1 to both 6.x and 7.x
Currently pondering #2. This would really only be a modification to a single pager. The thing is, there are times when you still want to know the full count, not just "is there more", so it's a bit tricky to make sure we don't break some cases trying to make one case more performant. #1 is easy and covers most of the cases anyway. So I think I want to skip #2 because I'm too concerned about cases where the actual count is needed and we suddenly decide not to fetch it.