Skip to content

perf(pluto): batch-fetch keys in getAllPrismDIDs to eliminate N+1 queries - #652

Open
A-Chronicle wants to merge 1 commit into
hyperledger-identus:mainfrom
A-Chronicle:perf/batch-prism-did-queries
Open

perf(pluto): batch-fetch keys in getAllPrismDIDs to eliminate N+1 queries#652
A-Chronicle wants to merge 1 commit into
hyperledger-identus:mainfrom
A-Chronicle:perf/batch-prism-did-queries

Conversation

@A-Chronicle

Copy link
Copy Markdown
Contributor

Description

getAllPrismDIDs() previously queried DIDKeyLinks and Keys individually for each prism DID (N+1 pattern — 1 query for DIDs + N queries for links + N queries for keys).

Applied the same batch-fetch pattern used by getAllPeerDIDs():

  1. Fetch all prism DIDs (1 query)
  2. Fetch all DIDKeyLinks for those DIDs (1 query)
  3. Fetch all Keys for those links (1 query)
  4. Assemble in memory — O(1) database round-trips

This also removes the private getPrismDIDS() helper that was only used by getAllPrismDIDs.

Fixes #649

Alternatives Considered

  • Keeping the existing pattern: simple but degrades with scale
  • Going further and also fixing getAllMediators (same N+1 issue) — left as follow-up since it has different structure

Checklist

  • My PR follows the contribution guidelines of this project
  • My PR is free of third-party dependencies that dont comply with the Allowlist
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked the PR title to follow the conventional commit specification

…ries

Signed-off-by: A-Chronicle <chaubeyanshika319@gmail.com>
@A-Chronicle
A-Chronicle requested a review from a team as a code owner May 25, 2026 15:15
@sonarqubecloud

Copy link
Copy Markdown

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.

perf: N+1 database queries in Pluto getAllPrismDIDs, getAllPeerDIDs, getAllMediators

1 participant