arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.16544cs.DB
收藏

First Past the Post:评估 MongoDB 中的查询优化

First Past the Post: Evaluating Query Optimization in MongoDB

Dawei Tao, Enqi Liu, Sidath Randeni Kadupitige, Michael Cahill, Alan Fekete, Uwe Röhm

AI总结:

本文分析了 MongoDB 的 FPTP 查询优化器有效性,发现其存在偏好索引扫描的偏差,导致所选计划运行时间可达最优计划的两倍以上。

摘要:

查询优化对于每个数据库管理系统(DBMS)实现声明式查询的快速执行至关重要。大多数 DBMS 设计包含基于成本的查询优化。然而,MongoDB 实现了一种不同的方法来选择执行计划,我们称之为“first past the post”(FPTP)查询优化。FPTP 不估计每个执行计划的成本,而是以轮询竞争的方式部分执行备选计划,并观察每个计划相对于返回记录数所完成的工作量。在本文中,我们分析了 MongoDB FPTP 查询优化器的有效性。我们考察优化器是否在备选方案中选择最佳执行计划,并测量所选计划与最优计划的对比情况。我们还展示了如何可视化其有效性,并识别出 MongoDB 7.0.1 查询优化器选择次优查询计划的情形。通过实验,我们得出结论:FPTP 存在偏好偏差,即使在许多集合扫描运行更快的情况下,它仍选择索引扫描。我们找出了导致这种偏好偏差的原因,这可能使 MongoDB 选择的计划运行时间超过该查询最优计划运行时间的两倍。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑