Database research has always given limited attention to optimizing predicates with disjunctions. What little past work there is, has mostly focused on optimizations for traditional row-oriented databases. However, a key difference between how row-oriented and column-oriented engines evaluate predicates is that while row-oriented engines apply predicates to a single tuple at a time, column-oriented engines apply predicates to sets of tuples, adding another dimension to the problem. As such, row-oriented engines focus only on the best order to apply predicates in to "short-circuit" the overall predicate expression, but column-oriented engines must additionally decide on the input sets of tuples for each predicate application. This is important, since smaller inputs lead to faster runtimes, and nontrivial, since the results of earlier predicates can be used to reduce the inputs to later predicates and predicates may be combined via disjunctions in the predicate expression. In this work, we formally analyze the predicate evaluation problem for column-oriented engines and present BestD/Update, the first ever polynomial-time, provably optimal algorithms to deduce the minimum input sets for each predicate application. BestD/Update's optimality is guaranteed under a wide range of cost models, representing different real-world scenarios. Furthermore, when combined with the predicate ordering algorithm Hanani, BestD/Update reduce into EvalPred, a simple O(n log^2 n) algorithm, which we recommend for practical use and optimal for all predicate expressions of nested depth 2 or less. Our evaluation shows, thanks to its optimality and polynomial planning time, EvalPred outperforms not implementing any disjunction optimizations and exiting optimal algorithms by up to 2.6x and 28x respectively for synthetic workloads and by up to 1.3x and 100x respectively for queries from TPC-H and the CH-benchmark.
翻译:数据库研究中,针对包含析取条件的谓词优化一直未得到足够重视。现有少量相关工作主要聚焦于传统行式数据库的优化策略。然而,行式引擎与列式引擎在谓词评估机制上存在根本差异:行式引擎每次仅将谓词应用于单条元组,而列式引擎则对元组集合进行谓词处理,这为问题增加了新的维度。因此,行式引擎只需关注谓词的最佳应用顺序以实现整体谓词表达式的“短路”优化,而列式引擎还需额外决定每次谓词应用所需的输入元组集合。这一决策至关重要——较小的输入集能有效缩短运行时间,且具有非平凡性:先前谓词的结果可用于缩减后续谓词的输入规模,而谓词表达式中的析取连接更增添了复杂性。本研究针对列式引擎的谓词评估问题开展形式化分析,首次提出具有多项式时间复杂度的最优算法BestD/Update,该算法能推导出每个谓词应用所需的最小输入集。BestD/Update在涵盖多种现实场景的广泛成本模型下均可保证全局最优性。进一步地,当与谓词排序算法Hanani结合时,BestD/Update可转化为EvalPred这一简洁的O(n log^2 n)算法,该算法兼顾实际应用价值,且对所有嵌套深度不超过2的谓词表达式均能实现最优求解。实验评估表明,凭借最优性保证和多项式级规划时间,相较于未实施析取优化策略的方法及现有最优算法,EvalPred在合成工作负载上分别获得最高2.6倍和28倍的性能提升,在TPC-H与CH-benchmark基准查询上则分别实现最高1.3倍和100倍的加速效果。