Skip to content

perf(listing): stop recounting products on every page and sort - #1283

Open
peelar wants to merge 1 commit into
mainfrom
perf/listing-reuse-total
Open

peelar wants to merge 1 commit into
mainfrom
perf/listing-reuse-total

Conversation

@peelar

@peelar peelar commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Saleor's totalCount is expensive: to answer it, Saleor counts every product that matches the filters. Paper asked for it on every listing request, even though going to the next page or changing the sort never changes the number.

Now the browser sends the count it already shows, and Saleor is only asked to count when the filters or search text change.

What the shopper does Before After
Opens "size M" Saleor counts Saleor counts
Clicks "Next page" Saleor counts again Reuses the count
Changes the sort Saleor counts again Reuses the count
  • Skipping the count: the listing queries select totalCount @include(if: $withTotal), so Saleor never computes it when the storefront already has it.
  • Cached pages: pages kept in the shared cache always count for themselves, so one shopper's number is never stored for everyone.

🤖 Generated with Claude Code

Saleor counts the whole filtered set for `totalCount` on every request.
Paging and sorting never change that count, so the PLP now sends the total
it already shows for the same filters to /api/listing, and the Saleor
provider skips `totalCount` with `@include(if: $withTotal)`. Cached views
drop the client total before the cache key and always count for themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
storefront Ready Ready Preview Dec 2, 2026 7:32am UTC

Request Review

@peelar peelar changed the title perf(listing): reuse the known total when paging or re-sorting perf(listing): stop recounting products on every page and sort Dec 2, 2026
@peelar
peelar marked this pull request as ready for review December 2, 2026 07:33
@peelar
peelar requested review from a team and mirekm as code owners December 2, 2026 07:33

This branch was successfully deployed

1 active deployment
Preview — 0aa2488d Deployed Dec 2, 2026 by vercel[bot]
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.

1 participant