This tag is for questions related to querying and updating MongoDB collections, either through the mongo shell or using a programming language driver.
This tag is for questions related to querying and updating MongoDB collections, either through the mongo
shell or using a programming language driver.
Unlike most relational databases, MongoDB does not support SQL (Structured Query Language). Queries in MongoDB are expressed in the MongoDB Query Language which uses JSON from the mongo
shell and BSON (Binary JSON) at the driver level.
MongoDB has a rich query language including many advanced operators as well as aggregation features such as the Aggregation Framework and Map-Reduce.
For effective query plans it is important to understand the indexing strategies and explain your slow queries to understand their index usage. By default, MongoDB will log all queries slower than 100ms (a slowms
value that can be adjusted either as a command-line option or within the mongo
shell).
MongoDB also includes a Database Profiler which can be enabled to capture either slow queries or all queries for a database.
Documentation
- MongoDB Query Language
- Indexing Overview
- Indexing Operations
- Indexing Strategies
- Query Optimizer
- Explaining Query Plans
- Database Profiler
- Advanced Queries
- Using Indexes to Sort Query Results
- Map-Reduce
- Aggregation Framework
- Aggregation Commands Comparison
- SQL to MongoDB Mapping Chart
- SQL to Aggregation Mapping Chart