How can test the performance of my query

lookup aggregation takes; time : 1174ms with size : 62.95kb is that normal ??
Here is my function below

if (role === ROLEV1.MS_TECH_SOFT) {
      let logs = await this.profileModel.aggregate([
          $match: {
            bindedSuperAdmin: name,
          $lookup: {
            from: 'tpes',
            localField: 'nameUser',
            foreignField: 'merchantName',
            as: 'tpesBySite',
          $lookup: {
            from: 'logs',
            localField: 'tpesBySite.terminalId',
            foreignField: 'terminalId',
            as: 'logsByTpes',
            pipeline: [
                $sort: {
                  transactionDate: -1,
                  // transactionDate: { $in: [startDate, endDate] },

        { $unwind: '$tpesBySite' },

        { $unwind: '$logsByTpes' },
          $project: {
            // bindedSuperAdmin: '$bindedSuperAdmin',
            // bindedBanque: '$bindedBanque',
            // bindedClient: '$bindedClient',
            uniqueID: '$logsByTpes.uniqueID',
            sn: '$',
            terminalId: '$logsByTpes.terminalId',
            transactionAmount: '$logsByTpes.transactionAmount',
            currencyCode: '$logsByTpes.currencyCode',
            transactionDate: '$logsByTpes.transactionDate',
            transactionTime: '$logsByTpes.transactionTime',
            transactionType: '$logsByTpes.transactionType',
            cardPAN_PCI: '$logsByTpes.cardPAN_PCI',
            outcome: '$logsByTpes.outcome',
      console.log(logs.length, ' length from ms prfile service');

      return logs;

Does this query could be better ? any help please

Were the answers given to you in previous threads useful? It will be nice to have closure on those before we invest time in your new problem.

I answered all my recent topics thank you @steevej for reminding me :slight_smile:

1 Like

The following still has no solution to it.

It is funny because so far it is more or less the same and only thing I can say for this thread as the other one.

  1. bindedSuperAdmin:1 on collection profileModel
  2. merchantName:1 on collection tpes
  3. terminalId:1 on collection logs

Many $lookup and many $unwind are worry signs indicating a potential model or schema flaw. It is hard to tell without sample documents and some explication on the context. If the use-case is not frequent, trying to optimize might be useless.