First Past the Post: Evaluating Query Optimization in MongoDB
摘要
Query optimization is crucial for every DBMS to enable fast execution of declarative queries. While most DBMS designs include cost-based query optimization, MongoDB chooses an execution plan by what we call “first past the post” (FPTP) query optimization. This partially executes the alternative plans in a round-robin race and observes the work done by each relative to the number of records returned. Through experiments, we analyze the effectiveness of MongoDB’s FPTP query optimizer, concluding that it chooses index scans even in many cases where collection scans would run faster. We identify the reasons for this.