![the mongo db optimizer is optimal the mongo db optimizer is optimal](https://static.carahsoft.com/concrete/files/8116/1409/5481/snap_shot_-_mongodb_ops_manager_datasheet.png)
If you use this method you'll narrow your choices radically and go straight to a good index. That's it! For complex queries on several fields, there's a heap of possible indexes to consider. Remember that if you have several indexes on a collection, you may need to hint Mongo to use the right index. You can omit some equality-test fields or range-filter fields if they are not selective, to decrease the index size-a rule of thumb is, if the field doesn't filter out at least 90% of the possible documents in your collection, it's probably better to omit it from the index. Then the next lowest-cardinality range filter, and so on to the highest-cardinality.First, add the range filter for the field with the lowest cardinality (fewest distinct values in the collection).Unlike InfluxDB, CrateDB was designed to optimize the use of resources under. Add sort fields to the index in the same order and direction as your query's sort It was not easy to pick up like MongoDB Learn about the best InfluxDB.Sort Fields (ascending / descending only matters if there are multiple sort fields).Consequently, for this example, the energy consumed by the air-conditioning unit for a. Query optimizer does best effort to detect when stage could be moved up to optimize. The Y-axis is the power rate in Kilowatts, and the X-axis is time to indicate when the device captured each reading. Learning MongoDB performance with MongoDB University, M201 - GitHub. Add all equality-tested fields to the compound index, in any order For this IoT Power Consumption example, the points on the graph represent an air-conditioning units power readings captured every 30 minutes.So here's my method for creating a compound index for a query combining equality tests, sort fields, and range filters: If my range filter on timestamp is selective, adding timestamp to the index is worthwhile if it's not selective then the additional size of the index won't be worth the price. But now, nscannedObjects is only 2, because Mongo can tell from the index entry alone that the comment with timestamp 1 isn't a match.
![the mongo db optimizer is optimal the mongo db optimizer is optimal](https://miro.medium.com/max/750/0*B1ZkxqwUG-qWlXop.jpg)
Mongo follows a similar plan as before, moonwalking across the "anonymous, rating, timestamp" index so it finds comments in the right order.