Prevent all results from loading

Created on 1 July 2021, about 4 years ago
Updated 18 June 2025, 25 days ago

Problem/Motivation

I have a View which displays products tagged by every year going back to 1990. I want to load only 4 results per year (4 * 30 = 120 results).

However, I have thousands of products and using this module, it seems to load ALL of the products. This results in a WSOD in production.

Steps to reproduce

  • Create a View which loads content/products with the Format 'Complex Grouping'
  • Group by a field, such as Year
  • Items to display: 4
  • If you have a lot of content/products (in my case, thousands) the page will end up white screening

Proposed resolution

I don't know much about writing queries, but when I turn on Views query debugging, it doesn't show the number '4' anywhere in the query. This is odd. Shouldn't the 'Items to display' number be appearing somewhere in the query?

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Component

Code

Created by

🇨🇦Canada trevorkjorlien

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇺Cuba dariemlazaro Havana

    I've been looking for a way to display a discrete sample of three content items per category using a Drupal view. The Representative Node works, but only for one item, and its option to display by view doesn't work, causing a SQL error. This module, on the other hand, allows for grouping by a defined number of items. It works for what I want, but causes a WSOD when there are too many items. It seems to load the entire database and then filter. A way to limit the SQL query to the defined number of items to be grouped would be needed. I have no knowledge of how to modify this SQL query or any other way to optimize this.

Production build 0.71.5 2024