Skip to content
CCPEDIAby Unity Nodes
#7136OPEN Issue

Scan `/v0/events` (`getEventHistory`) does one `listTransactionViews` query per verdict

stephencompall-DA04-09-2026Last activity 1d ago

ScanEventStore#getEvents fetches a page of verdicts, then makes one extra query per verdict in the page to fetch each verdict's transaction views:

https://github.com/canton-network/splice/blob/a4ea43aa55db83a028a30e95ace45e1350edde9a/apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/ScanEventStore.scala#L85-L89

Each of those calls is a separate query on scan_verdict_transaction_view_store:

https://github.com/canton-network/splice/blob/1b6c1bb3bb6ca99334fd95595c2f065e685c4bd7/apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/db/DbScanVerdictStore.scala#L630-L647

Up to 1000 verdicts are fetched, so up to 1000 queries may be made.

Instead of the existing listTransactionViews, add a listTransactionViews(verdictRowIds: Seq[Long]) that uses isInClause and regroup the results in memory. It should use a limit of the length of verdictRowIds.

Compare to the existing example for AppActivityRecords:

https://github.com/canton-network/splice/blob/a4ea43aa55db83a028a30e95ace45e1350edde9a/apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/db/DbAppActivityRecordStore.scala#L286-L306

This can be tested by comparing the results from traversing with the existing single-ID function to those from the batch function for equality.

Introduced by #2039.

← Back to Proposals