Unfortunately I cannot provide the RPU costs for the queries you have provided since it depends on the exact situation but hopefully the below details may help with understanding how the RPU’s are calculated.
The best database deployment for you depends on your use case and feature requirements. You may choose a serverless instance if you want to:
- Get started quickly with minimal database configuration.
- Have your database scale automatically and dynamically to meet your workload.
- Run infrequent or sparse workloads.
- Develop or test in a cloud environment.
To help you to choose the best database deployment type, you can find more details about use cases, feature support, and comparisons in our choosing database deployment type documentation.
Read Processing Units are accrued per operation and Atlas charges one RPU for each document read (up to 4 KB) or for each index read (up to 256 bytes) when covered queries (can be satisfied by an index). For more information, please see the Serverless Instance Costs documentation.
Please note that a single read operation often does not equate to 1 RPU. One read operation can result in many RPUs depending on how the query is structured, how your data is structured, how large the documents are, among other things. In the most basic terms, RPUs represent how much work the server needs to do to fulfill your query (more on this below). Atlas meters based on the units of documents and index data read that meet the criteria outlined on our Serverless Instance Costs linked above.
During a query’s execution it may need to read a lot more data to determine what documents to return. For example, If a query involves a COLLSCAN (Collection Scan), then it can charge many RPUs as it reads all document bytes in a collection regardless of how many documents are returned.
In aggregation pipelines, all necessary documents scanned to fulfill the query contribute to the RPUs. This can include documents scanned, documents sorted, documents grouped in aggregation, and documents returned.
For guidance on optimizing aggregation pipeline performance review the following documentation links:
The Storage in the serverless instances includes the logical document and index storage. This value includes the number of bytes of all uncompressed BSON documents stored in all collections, plus the bytes stored in their associated indexes.
The best practice to reduce RPUs is to use indexes. Indexes reduce the ratio of the number of documents scanned to the number of documents returned by queries.
Using indexes improves your search queries and reduce the RPUs performed on your Atlas instance. If your application is running infrequent loads but you notice that you still incur high RPU costs, this is an indication that your queries are not optimized or your application is not using efficient indexes. See the Indexing Strategies documentation for improving the use of your indexes.
For more reading and examples about Serverless costs, see the blog post Serverless Instances Billing 101: How to Optimize Your Bill with Indexing.
Regards,
Jason