Skip to content

perf(graphql): optimized join count when docs are not needed#14872

Merged
DanRibbens merged 1 commit intopayloadcms:mainfrom
rjgtav:rjgtav/perf-graphql-join-count
Jan 7, 2026
Merged

perf(graphql): optimized join count when docs are not needed#14872
DanRibbens merged 1 commit intopayloadcms:mainfrom
rjgtav:rjgtav/perf-graphql-join-count

Conversation

@rjgtav
Copy link
Contributor

@rjgtav rjgtav commented Dec 9, 2025

What?

Optimizes the count of a join field when the goal is just to retrieve the count value (i.e. limit: 0).

Why?

Generates 1 database query instead of two when the goal is just to retrieve the count value.

How?

By using payload.count() instead of payload.find()

Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice small optimization!

@DanRibbens DanRibbens merged commit 6025eff into payloadcms:main Jan 7, 2026
99 checks passed
teastudiopl pushed a commit to teastudiopl/payload that referenced this pull request Jan 8, 2026
…cms#14872)

### What?
Optimizes the count of a join field when the goal is just to retrieve
the count value (i.e. limit: 0).

### Why?
Generates 1 database query instead of two when the goal is just to
retrieve the count value.

### How?
By using payload.count() instead of payload.find()

Co-authored-by: Ricardo Tavares <[email protected]>
@github-actions
Copy link
Contributor

🚀 This is included in version v3.71.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants