From b11741af29ff6b4e17e38d6eae98fcf350fb4816 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Thu, 7 Nov 2024 23:43:19 -0500 Subject: [PATCH] perf(core): add missing index for paginated query --- core/api/src/services/ledger/schema.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/api/src/services/ledger/schema.ts b/core/api/src/services/ledger/schema.ts index 88fa411a85..15a5e2b1c8 100644 --- a/core/api/src/services/ledger/schema.ts +++ b/core/api/src/services/ledger/schema.ts @@ -162,6 +162,12 @@ transactionSchema.index({ payout_id: 1 }) transactionSchema.index({ _original_journal: 1 }) transactionSchema.index({ related_journal: 1 }) transactionSchema.index({ external_id: 1 }) +transactionSchema.index({ + "book": 1, + "account_path.0": 1, + "account_path.1": 1, + "_id": -1, +}) // indexes used by balance queries transactionSchema.index({ book: 1, accounts: 1, currency: 1, _id: 1 })