From 72f11a8c82e7890556651ef66d659d33f9b5d584 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 19 Sep 2026 12:50:46 +0200 Subject: [PATCH] Task/improve watchlist performance by removing market price index of market data database table (#7907) * Improve watchlist performance * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/endpoints/watchlist/watchlist.service.ts | 2 ++ .../migration.sql | 2 ++ prisma/schema.prisma | 1 - 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20260919000000_removed_index_for_market_price_from_market_data/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index d2f55ca20c..9dd8c7f995 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Localized the default account name created during user registration +- Improved the performance of the watchlist by removing an unnecessary index from the market data table - Improved the performance of deleting a watchlist item - Extended the `POST api/v1/user` endpoint by the language code - Improved the language localization for German (`de`) diff --git a/apps/api/src/app/endpoints/watchlist/watchlist.service.ts b/apps/api/src/app/endpoints/watchlist/watchlist.service.ts index 53076b311c..ccdd04e27c 100644 --- a/apps/api/src/app/endpoints/watchlist/watchlist.service.ts +++ b/apps/api/src/app/endpoints/watchlist/watchlist.service.ts @@ -1,3 +1,4 @@ +import { LogPerformance } from '@ghostfolio/api/interceptors/performance-logging/performance-logging.interceptor'; import { BenchmarkService } from '@ghostfolio/api/services/benchmark/benchmark.service'; import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; @@ -88,6 +89,7 @@ export class WatchlistService { }); } + @LogPerformance public async getWatchlistItems( userId: string ): Promise { diff --git a/prisma/migrations/20260919000000_removed_index_for_market_price_from_market_data/migration.sql b/prisma/migrations/20260919000000_removed_index_for_market_price_from_market_data/migration.sql new file mode 100644 index 0000000000..16d09d292a --- /dev/null +++ b/prisma/migrations/20260919000000_removed_index_for_market_price_from_market_data/migration.sql @@ -0,0 +1,2 @@ +-- DropIndex +DROP INDEX "MarketData_marketPrice_idx"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7e4b15bfb3..8d874b4de6 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -172,7 +172,6 @@ model MarketData { @@index([dataSource]) @@index([dataSource, symbol]) @@index([date]) - @@index([marketPrice]) @@index([state]) @@index([symbol]) }