MongoDB Atlas serverless billing for aggregate query lookup

I received a bill that was higher than expected for my server less database. Many of the queries I was making include aggregate lookup operations for documents in other collections (sometimes hundreds of lookups for one query) .

According to the serverless pricing information:
“You are charged one RPU for each document read (up to 4KB) or for each index read (up to 256 bytes).”

Just to make things crystal clear, does that mean I am charged one RPU for each aggregate lookup performed? E.g. If I query a document with 100 ids that I want replaced with their corresponding documents and through aggregate operations end up doing 100 lookups, I am charged 101 RPUs (one to query the original document and then 100 for each id lookup) for that query?

Hi @penguinlover and welcome to the MongoDB community forum!!

The RPU in MongoDB Atlas is charged depending on the number of documents being scanned for the the query and not on the documents being returned from the query.

Generally, the RPU that forms the basis of serverless charges concerns about the work needed to be performed by MongoDB to service the work. As an example, if a query were to cause a collection scan and return 0 documents, MongoDB still has to service the collection scan and the appropriate RPU’s would be charged accordingly.

However, indexes is one of the many factors which would determine the pricing for the read and write. The other factor which should also be taken into consideration is the document size read as noted in the quote you posted from the Atlas Billing Documentation.

Let us know if you have any further queries.

Best Regards
Aasawari