Browse Source

Task/improve performance of historical market data query (#8061)

* Improve performance of historical market data query

* Update changelog
pull/8109/head
Thomas Kaul 9 hours ago
committed by GitHub
parent
commit
3ecf11bb98
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 11
      apps/api/src/services/data-provider/data-provider.service.ts

1
CHANGELOG.md

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Extended the benchmark comparator to support benchmarks whose market data starts later than the portfolio - Extended the benchmark comparator to support benchmarks whose market data starts later than the portfolio
- Harmonized the colors in the investment chart component - Harmonized the colors in the investment chart component
- Improved the performance of getting the historical market data by loading only the requested asset profiles
- Improved the language localization for Chinese (`zh`) - Improved the language localization for Chinese (`zh`)
### Fixed ### Fixed

11
apps/api/src/services/data-provider/data-provider.service.ts

@ -403,12 +403,8 @@ export class DataProviderService implements OnModuleInit {
})}::timestamp` })}::timestamp`
: Prisma.empty; : Prisma.empty;
const dataSources = aItems.map(({ dataSource }) => { const assetProfileIdentifiers = aItems.map(({ dataSource, symbol }) => {
return dataSource; return Prisma.sql`(${dataSource}::"DataSource", ${symbol})`;
});
const symbols = aItems.map(({ symbol }) => {
return symbol;
}); });
try { try {
@ -416,8 +412,7 @@ export class DataProviderService implements OnModuleInit {
.$queryRaw` .$queryRaw`
SELECT * SELECT *
FROM "MarketData" FROM "MarketData"
WHERE "dataSource"::text IN (${Prisma.join(dataSources)}) WHERE ("dataSource", "symbol") IN (${Prisma.join(assetProfileIdentifiers)})
AND "symbol" IN (${Prisma.join(symbols)})
${granularityQuery} ${granularityQuery}
${rangeQuery} ${rangeQuery}
ORDER BY date;`; ORDER BY date;`;

Loading…
Cancel
Save