perf: group catalog source reads by identity
Backend verify / commits (push) Skipped
Backend verify / security (push) Successful in 9s
Backend verify / verify (push) Failing after 11m54s

This commit was merged in pull request #40.
This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent b24433092b
commit 6cd9c2dd28
2 changed files with 58 additions and 2 deletions
@@ -123,11 +123,23 @@ export class CatalogDiscoveryRepository {
}
readSources(inputs: CatalogSource[]) {
// Share identity predicates across UIDs instead of preparing one OR per row.
const groups = new Map<string, CatalogSource[]>();
for (const input of inputs) {
const key = JSON.stringify([
input.kind,
sourceProvider(input),
input.kind === 'detail' ? input.instrumentType : (input.rangeKey ?? ''),
]);
const group = groups.get(key);
if (group) group.push(input);
else groups.set(key, [input]);
}
return this.prisma.tbankInstrumentSource.findMany({
where: {
provider,
OR: inputs.map((input) => ({
instrumentUid: input.uid,
OR: [...groups.values()].map(([input, ...rest]) => ({
instrumentUid: { in: [input, ...rest].map((entry) => entry.uid) },
kind: input.kind,
source: sourceProvider(input),
rangeKey: