Skip to content

[6.x] Only send the counts of replicator sets and grid rows to listings - #15811

Merged
jasonvarga merged 2 commits into
statamic:6.xfrom
DanielDarrenJones:perf/6x-cp-listing-set-counts
Nov 20, 2026
Merged

jasonvarga merged 2 commits into
statamic:6.xfrom
DanielDarrenJones:perf/6x-cp-listing-set-counts

Conversation

@DanielDarrenJones

@DanielDarrenJones DanielDarrenJones commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

When a replicator or grid column is shown in a listing (entries, terms, users, assets or form submissions), every row carries that field's whole value, nested sets and all. The listing cell only shows how many there are (:count sets / :count rows), and it gets that by counting the array.

This adds preProcessIndex() to both fieldtypes so they send the count instead: Replicator returns the number of sets and Grid returns the number of rows. Non-arrays and null pass through unchanged.

The index components already pass the value to __n(), which accepts a number as well as an array, so the cell reads exactly the same. Their v-if now checks for null instead of truthiness so an empty field still shows "0 sets" / "0 rows" rather than nothing. Bard has its own preProcessIndex() and isn't affected.

Benchmark

A generated site on 6.40.0 with an 85 KB page builder blueprint. Each request runs in its own PHP process, as PHP-FPM serves it (boot not timed, opcache on), median of 5, on an M1 Pro with PHP 8.5.

A 50-entry listing with the page builder column visible goes from 1.06 MB to 27 KB and from 80 ms to 66 ms.

These numbers were measured against an earlier version of this PR that sent each set's id, type and enabled (and each row's id) rather than a count. Sending a count should only be slightly smaller than that, so it wasn't remeasured.

I also checked the CP in a browser on stock 6.40.0 and with this change: the listing table renders identically, including a grid column with 3 to 8 rows per entry and a Bard column next to it. The count version was also checked in a browser, including fields with sets/rows, empty arrays (0 sets / 0 rows) and no value (blank).

Compatibility

An addon fieldtype that extends Replicator or Grid and has its own index component that reads the value as an array (iterating it, or showing the set or row contents) would now get a number. It can override preProcessIndex() to keep the old behaviour. I couldn't find a public addon that does this.

Tests

  • ViewEntryListingTest::it_only_lists_the_counts_of_replicator_sets_and_grid_rows (fails without the change).
  • ReplicatorTest and GridTest cover the count, and that non-arrays and null pass through.

DanielDarrenJones and others added 2 commits November 7, 2026 02:12
The listing cell only shows a count, so send the count itself rather than a trimmed array. The index components now check for null so an empty field still shows 0 sets / 0 rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasonvarga jasonvarga changed the title [6.x] Only send the ids and types of replicator sets and grid rows to listings [6.x] Only send the counts of replicator sets and grid rows to listings Nov 20, 2026
@jasonvarga
jasonvarga merged commit 294c101 into statamic:6.x Nov 20, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants