Skip to content

feat: improve query performance for manage permissions - #1900

Merged
paustint merged 1 commit into
mainfrom
feat/improve-permission-query-performance
Aug 2, 2026
Merged

feat: improve query performance for manage permissions#1900
paustint merged 1 commit into
mainfrom
feat/improve-permission-query-performance

Conversation

@paustint

@paustint paustint commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Queries are now paginated by DurableId so we no longer need to rely on Salesforce query pagination which is very limited for EntityParticle

Copilot AI review requested due to automatic review settings August 1, 2026 21:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 createConcurrencyLimiter utility (with tests) to cap in-flight async work across multiple query groups.
  • Introduced queryAllUsingCursor for 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.

Comment thread libs/shared/data/src/lib/client-data.ts
Queries are now paginated by DurableId so we no longer need to rely on Salesforce query pagination which is very limited for EntityParticle
Copilot AI review requested due to automatic review settings August 2, 2026 18:48
@paustint
paustint force-pushed the feat/improve-permission-query-performance branch from 8097ef6 to 55d6c65 Compare August 2, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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()?.();
    }

@paustint
paustint merged commit c78cfba into main Aug 2, 2026
9 checks passed
@paustint
paustint deleted the feat/improve-permission-query-performance branch August 2, 2026 19:05
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