Quick Answer
MongoDB uses the query planner to select the best index. When multiple indexes could satisfy a query, the planner runs a "tournament" - it executes candidate plans in parallel for a trial period and picks the winner (fewest works to return the first batch of results). The winner is cached in the plan cache. Provide hints (db.collection.find().hint()) to force a specific index.
Answer
MongoDB tests candidate plans during a trial phase and caches the best plan to avoid repeated plan selection.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.
MongoDB interview questions and answers for beginner, junior, mid-level, senior, and expert developers. Perfect for freshers and experienced candidates.