Skip to content

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

Task/improve watchlist performance by removing market price index of market data database table (#7907)

Thomas Kaul72f11a8c82e7
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<WatchlistResponse['watchlist']> {
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])
}