vix.ing · top · new · best · stats · spec

First Past the Post: Evaluating Query Optimization in MongoDB

2024/09/25 by Dawei Tao, Tao, Dawei, Enqi Liu +10 · 1 voice
Computer Science · #Advanced Database Systems and Queries #Cloud Computing and Resource Management #IoT and Edge/Fog Computing #cs.DB

paper · pdf · doi:10.48550/arxiv.2409.16544

openalex publication_date 2024/09/25 · openalex created_date 2025/10/10 · openalex updated_date 2026/07/28

Abstract

Query optimization is crucial for every database management system (DBMS) to enable fast execution of declarative queries. Most DBMS designs include cost-based query optimization. However, MongoDB implements a different approach to choose an execution plan that we call "first past the post" (FPTP) query optimization. FPTP does not estimate costs for each execution plan, but rather partially executes the alternative plans in a round-robin race and observes the work done by each relative to the number of records returned. In this paper, we analyze the effectiveness of MongoDB's FPTP query optimizer. We see whether the optimizer chooses the best execution plan among the alternatives and measure how the chosen plan compares to the optimal plan. We also show how to visualize the effectiveness and identify situations where the MongoDB 7.0.1 query optimizer chooses suboptimal query plans. Through experiments, we conclude that FPTP has a preference bias, choosing index scans even in many cases where collection scans would run faster. We identify the reasons for the preference bias, which can lead MongoDB to choose a plan with more than twice the runtime compared to the optimal plan for the query.

Discussions

Related