Map-reduce Query Performance Optimisation

Hello Team,

Can someone help me to optimize the following map-reduce query. The following query is pulling the data from another collection and rolling up and storing the data based roll-up type by minutes, weeks, days and months. I tried to optimize the query based on creating indexes on query and sorting fields but still the query shows same execution time. I can the see the index stats shows the query is hitting the indexes but no improvement on optimization. I am not sure if the Map-reduce uses the indexes for the execution of the query.

Following the query :-

print(" Reduce Funtion v1.2 for collection name. Initialized with Configuration as “+tojsononeline(confi…”, out: { reduce: “collection name”, db: “db2”, sharded: true, nonAtomic: true }, query: { executorId: “xxxx” }, sort: { container: 1, binding: 1, contract: 1, organization: 1, clientid: 1, operation: 1, service: 1, request.status: 1, timestamp: 1, _recordedOn: 1 }, scope: { externalFunctions: , externalMapFunctions: {}, externalReduceFunctions: {}, config: { debug: false, preaggregated: false }, rollup: [ { type: “HOURS”, executorId: “xxx”, deleteOn: -1, aggregate: [ { offset: 0, timezone: [ “UTC”, “GMT” ] } ] }, { type: “MINUTES”, executorId: “xxx”, deleteOn: -1 }, { type: “DAYS”, executorId: “xxx”, deleteOn: -1, aggregate: [ { offset: 0, timezone: [ “UTC”, “GMT” ] } ] }, { type: “WEEK”, executorId: “xxxx”, deleteOn: -1, aggregate: [ { offset: 0, timezone: [ “UTC”, “GMT” ] } ] }, { type: “YEAR”, executorId: “1dfa61e0-b4dc-4159-9f2a-9faac788a46f”, deleteOn: -1, aggregate: [ { offset: 0, timezone: [ “UTC”, “GMT” ] } ] }, { type: “MONTH”, executorId: “xxx”, deleteOn: -1, aggregate: [ { offset: 0, timezone: [ “UTC”, “GMT” ] } ] } ] }, maxTimeMS: 600000, verbose: false, $db: “db1”, $clusterTime: { clusterTime: Timestamp(1597349910, 23), signature: { hash: BinData(0, A86038C9CC686E87C74066D28ADBE485C1595FB7), keyId: 6815041461461975044 } }, lsid: { id: UUID(“02e832c3-f640-4794-9f75-cec9f9ab87dc”) } }, inputDB: “db1”, shardedOutputCollection: “tmp.mrs.collection”, writeConcern: { w: 1, wtimeout: 0 }, , $configServerState: { opTime: { ts: Timestamp(1597349910, 123), t: 20 } }, $db: “db2” } numYields:0 reslen:5004 locks:{ Global: { acquireCount: { r: 412, w: 304, W: 98 }, acquireWaitCount: { W: 36 }, timeAcquiringMicros: { W: 1927 } }, Database: { acquireCount: { r: 5, w: 302, W: 3 } }, Collection: { acquireCount: { r: 5, w: 101 } }, Metadata: { acquireCount: { W: 1 } }, oplog: { acquireCount: { w: 202 } } } protocol:op_query 538ms

Any help on this would be greatly appreciated.