[SERVER-60955] $count stage is working too slow in mongoDb aggregation query Created: 23/Oct/21  Updated: 06/Dec/22  Resolved: 01/Nov/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ankit Saini Assignee: Backlog - Triage Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Triage
Operating System: ALL
Participants:

 Description   

Hello Sir/Madam,

 

I have around 6 million products in my database and I am using atlas search to refine my search result. Everything is working fine, only $count stage is working slow. 

 
totalItems = Product.aggregate([
          {
            $search: {
              autocomplete: {
                query: searchQuery,
                path: normal_path,
                score: {
                  boost:

{                     value: 2,                   }

,
                },
              },
            },
          },
          {
            $project: {
              _id: 0,
              score:

{                 $meta: "searchScore",               }

,
            },
          },
          {
            $match:

{               score: \{ $gt: 15 }

,
            },
          },
         

{             $limit: 100,           }

,
         

{             $count: "count",           }

,
        ]);
 



 Comments   
Comment by Edwin Zhou [ 01/Nov/21 ]

Hi tech@shopmebook.com,

Thanks for your report. For this issue we'd like to encourage you to start by asking our community for help by posting on the MongoDB Developer Community Forums.

If the discussion there leads you to suspect a bug in the MongoDB server, then we'd want to investigate it as a possible bug here in the SERVER project.

Best,
Edwin

Generated at Thu Feb 08 05:51:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.