perf: optimize DB connections, queries, and indexes

Fix dev-mode reconnect storm by persisting mongoose connection state on
globalThis instead of a module-level flag that resets on Vite HMR.

Eliminate redundant in_season DB query on /rezepte — derive seasonal
subset from all_brief client-side. Parallelize all page load fetches.

Replace N+1 settlement queries in balance route with single batch $in
query. Parallelize balance sum and recent splits aggregations.

Trim unused dateModified/dateCreated from recipe brief projections.

Add indexes: Payment(date, createdAt), PaymentSplit(username),
Recipe(short_name), Recipe(season).
This commit is contained in:
2026-04-06 12:42:45 +02:00
parent 1fa2e350d7
commit fac140b793
7 changed files with 74 additions and 71 deletions
+2
View File
@@ -193,6 +193,8 @@ const RecipeSchema = new mongoose.Schema(
);
// Indexes for efficient querying
RecipeSchema.index({ short_name: 1 });
RecipeSchema.index({ season: 1 });
RecipeSchema.index({ "translations.en.short_name": 1 });
RecipeSchema.index({ "translations.en.translationStatus": 1 });