feat: improve query performance for manage permissions - #1900
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Manage Permissions query performance by switching EntityParticle fetching away from OFFSET-based pagination (limited to OFFSET 2000) to keyset pagination using a DurableId cursor, and by adding a shared request-level concurrency limiter to prevent request floods while keeping overall loads fast.
Changes:
- Added a reusable
createConcurrencyLimiterutility (with tests) to cap in-flight async work across multiple query groups. - Introduced
queryAllUsingCursorfor keyset pagination on a strictly increasing cursor field. - Updated Manage Permissions EntityParticle query construction and data-loading flow to page by DurableId and share a single concurrency limiter across all requests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libs/shared/utils/src/lib/utils.ts | Adds a small concurrency-limiting queue utility for async tasks. |
| libs/shared/utils/src/lib/tests/create-concurrency-limiter.spec.ts | Adds deterministic unit tests validating limiter behavior (limit, queuing, rejection handling). |
| libs/shared/data/src/lib/client-data.ts | Adds cursor-based pagination helper (queryAllUsingCursor) for objects that can’t use queryMore / large OFFSET. |
| libs/features/manage-permissions/src/utils/permission-manager-utils.ts | Reworks EntityParticle query building to support DurableId cursor paging and larger per-query object chunks. |
| libs/features/manage-permissions/src/utils/tests/permission-manager-permissionable-fields-query.spec.ts | Adds tests for the new permissionable-fields query shape and chunking behavior. |
| libs/features/manage-permissions/src/usePermissionRecords.tsx | Uses cursor paging for EntityParticle and introduces a shared concurrency limiter across all query groups. |
Queries are now paginated by DurableId so we no longer need to rely on Salesforce query pagination which is very limited for EntityParticle
paustint
force-pushed
the
feat/improve-permission-query-performance
branch
from
August 2, 2026 18:48
8097ef6 to
55d6c65
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
libs/shared/utils/src/lib/utils.ts:264
waitingForSlot.shift()is O(n) because it has to reindex the whole array each time a task finishes. If a caller queues a large number of tasks (which is exactly when a limiter is most useful), this can turn into avoidable quadratic overhead. Consider switching to a simple head-index queue so releasing a slot is O(1).
} finally {
runningCount--;
waitingForSlot.shift()?.();
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Queries are now paginated by DurableId so we no longer need to rely on Salesforce query pagination which is very limited for EntityParticle