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
parent
commit
1f9c3dd2f4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 2
      apps/api/src/services/market-data/market-data.service.ts
  3. 2
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts
  4. 8
      prisma/migrations/20261005000000_updated_indexes_of_market_data/migration.sql
  5. 3
      prisma/schema.prisma

1
CHANGELOG.md

@ -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`

2
apps/api/src/services/market-data/market-data.service.ts

@ -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

2
apps/api/src/services/queues/data-gathering/data-gathering.service.ts

@ -348,7 +348,7 @@ export class DataGatheringService {
},
update: { marketPrice, isCarriedForward: false },
where: {
dataSource_date_symbol: {
dataSource_symbol_date: {
dataSource,
symbol,
date: startOfUtcDate

8
prisma/migrations/20261005000000_updated_indexes_of_market_data/migration.sql

@ -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";

3
prisma/schema.prisma

@ -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])

Loading…
Cancel
Save