MongoDB Atlas Search - slow count of matched documents

Hello, I have a collection with 11M records, which contains among other properties, a “Name” property with a client name:

    "Name" : "Teressa Bella"

I have created an Atlas Search index on the “Name” field with the following definition:

  "mappings": {
    "dynamic": false,
    "fields": {
      "Name": {
        "analyzer": "lucene.standard",
        "type": "string"

My use case counting all the documents that match a certain term which I’m doing like so:

    $search: {
      "text": {
        "query": "Teressa",
        "path": "Name"
    $count: "total"

The problem is that this query takes about 40s to complete on an M30 Atlas cluster (sometimes 10s or 20s if entirely fetched from memory, I presume).
Is this within the expected execution time for matching a term on 11M documents?
I would appreciate any suggestions on how i can optimize this kind of query.

I would try to project just the Name field. Since it is part of the index it is likely that the documents do no need be read from permanent storage.

This being said, if your use-case for using the Atlas Search is as simple as this, a normal index on the Name field might be a better fit.

Thanks for the tip, unfortunately it didn’t make a difference, probably because I’m only performing a count on the records.
My real use case will actually include more complex operations, like partial text searches. However, as I performed this simple test, i found the performance to be worse than I was expecting, so I was looking to know if there’s something I’m missing.

I got same problem !

But i have 500k documents and M40.

For same search as you, searching time was between 40s-50s…

Any help from Mongo Employee ?

@Jonathan_Gautier we should set up some time to chat. I want to help you and feel your pain.

Same with you @Pedro_Cristina. I’m the new Product Manager on Atlas Search and I want to make this better for you both.

1 Like


Hi how can we help you to fix this issue ?

I have try to change my cluster tier from m30 to m50 but no change for search delay.
Guys from developper support said i need to change my cluster tier because m30 was overload but with m50 i got same result and it was not overload when my query was running.


New test today:

Search index size was : 4,84MB


496 688 documents match from query.
And take 27sec.

Same query with $project ( Fields “status” not indexed )

[{$project: {"status": { "$gte": ["$status", 0] }}},{"$count":"total"}]

Take 700ms

I have made many tests and every time “large match from query” with search was made, this take several time same for simplest query.

Is not normal i think but i dont know how it’s work behind :slight_smile:

If i can made some tests for you dont hesitate :wink:

Is it possible to reduce response time by using $search pipeline?
or I am using wildcard in $search, is it possible to use similar to wildcard in $project?

eventually. It’s being built now.

Hi Marcus, any updates?

This work has been started and it is coming in the next month or two. It will be lightning fast and it will also be usable in MongoDB Charts. If you’d like to be updated when this feature is released you can vote for it here