Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/select only required columns in historical market data query (#8110)

Thomas Kaul5df95d68c75d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff41dba99d..919032a762 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Extended the access to share the portfolio with the Model Context Protocol (MCP) to support the _View_ and the _View and manage_ permissions (experimental)
+- Improved the performance of getting the historical market data by selecting only the required columns
## 3.83.0 - 2026-10-10
diff --git a/apps/api/src/services/data-provider/data-provider.service.ts b/apps/api/src/services/data-provider/data-provider.service.ts
index 7bd06b1c99..5ddd5182d0 100644
--- a/apps/api/src/services/data-provider/data-provider.service.ts
+++ b/apps/api/src/services/data-provider/data-provider.service.ts
@@ -408,9 +408,11 @@ export class DataProviderService implements OnModuleInit {
});
try {
- const marketDataByGranularity: MarketData[] = await this.prismaService
- .$queryRaw`
- SELECT *
+ const marketDataByGranularity: Pick<
+ MarketData,
+ 'dataSource' | 'date' | 'marketPrice' | 'symbol'
+ >[] = await this.prismaService.$queryRaw`
+ SELECT "dataSource", "date", "marketPrice", "symbol"
FROM "MarketData"
WHERE ("dataSource", "symbol") IN (${Prisma.join(assetProfileIdentifiers)})
${granularityQuery}