Browse Source
Task/improve performance of latest market data (#8059)
* Improve performance of latest market data
* Update changelog
pull/7816/head^2
Thomas Kaul
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
12 additions and
4 deletions
-
CHANGELOG.md
-
apps/api/src/services/market-data/market-data.service.ts
-
apps/api/src/services/queues/data-gathering/data-gathering.service.ts
-
prisma/migrations/20261005000000_updated_indexes_of_market_data/migration.sql
-
prisma/schema.prisma
|
|
|
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
### Changed |
|
|
|
|
|
|
|
- Improved the performance of getting the latest market data by optimizing the indexes of the market data table |
|
|
|
- Deprecated `SymbolProfile` in favor of `assetProfile` in the endpoint `POST api/v1/activities` |
|
|
|
- Upgraded `Nx` from version `23.1.1` to `23.2.1` |
|
|
|
|
|
|
|
|
|
|
|
@ -248,7 +248,7 @@ export class MarketDataService { |
|
|
|
state: state as MarketDataState |
|
|
|
}, |
|
|
|
where: { |
|
|
|
dataSource_date_symbol: { |
|
|
|
dataSource_symbol_date: { |
|
|
|
dataSource: dataSource as DataSource, |
|
|
|
date: date as Date, |
|
|
|
symbol: symbol as string |
|
|
|
|
|
|
|
@ -348,7 +348,7 @@ export class DataGatheringService { |
|
|
|
}, |
|
|
|
update: { marketPrice, isCarriedForward: false }, |
|
|
|
where: { |
|
|
|
dataSource_date_symbol: { |
|
|
|
dataSource_symbol_date: { |
|
|
|
dataSource, |
|
|
|
symbol, |
|
|
|
date: startOfUtcDate |
|
|
|
|
|
|
|
@ -0,0 +1,8 @@ |
|
|
|
-- CreateIndex |
|
|
|
CREATE UNIQUE INDEX "MarketData_dataSource_symbol_date_key" ON "MarketData"("dataSource", "symbol", "date"); |
|
|
|
|
|
|
|
-- DropIndex |
|
|
|
DROP INDEX "MarketData_dataSource_symbol_idx"; |
|
|
|
|
|
|
|
-- DropIndex |
|
|
|
DROP INDEX "MarketData_dataSource_date_symbol_key"; |
|
|
|
@ -173,9 +173,8 @@ model MarketData { |
|
|
|
state MarketDataState @default(CLOSE) |
|
|
|
symbol String |
|
|
|
|
|
|
|
@@unique([dataSource, date, symbol]) |
|
|
|
@@unique([dataSource, symbol, date]) |
|
|
|
@@index([dataSource]) |
|
|
|
@@index([dataSource, symbol]) |
|
|
|
@@index([date]) |
|
|
|
@@index([state]) |
|
|
|
@@index([symbol]) |
|
|
|
|