Graph queries that combine pattern matching with relational operations, referred as PatRelQuery, are widely used in many real-world applications. It allows users to identify arbitrary patterns in a graph and further perform in-depth relational analysis on the results. To effectively support PatRelQuery, two key challenges need to be addressed: (1) how to optimize PatRelQuery in a unified framework, and (2) how to handle the arbitrary type constraints in patterns in PatRelQuery. In this paper, we present a graph-native query optimization framework named GOpt, to tackle these issues. GOpt is built on top of a unified intermediate representation (IR) that is capable of capturing both graph and relational operations, thereby streamlining the optimization of PatRelQuery. To handle the arbitrary type constraints, GOpt employs an automatic type inference approach to identify implicit type constraints. Additionally, GOpt introduces a graph-native optimizer, which encompasses an extensive collection of optimization rules along with cost-based techniques tailored for arbitrary patterns, to optimize PatRelQuery. Through comprehensive experiments, we demonstrate that GOpt can achieve significant query performance improvements, in both crafted benchmarks and real-world applications.
翻译:结合模式匹配与关系操作的图查询(称为PatRelQuery)广泛应用于众多实际场景中。此类查询允许用户在图中识别任意模式,并进一步对结果执行深入的关系分析。为了有效支持PatRelQuery,需要解决两个关键挑战:(1)如何在统一框架中优化PatRelQuery;(2)如何处理PatRelQuery中模式的任意类型约束。本文提出了一种名为GOpt的图原生查询优化框架以应对上述问题。GOpt构建于能够同时捕获图操作和关系操作的统一中间表示(IR)之上,从而简化了PatRelQuery的优化流程。针对任意类型约束,GOpt采用自动类型推断方法识别隐式类型约束。此外,GOpt引入了图原生优化器,该优化器包含针对任意模式的大量优化规则与基于代价的技术,以实现PatRelQuery的优化。通过全面的实验,我们证明GOpt在定制基准测试和实际应用中均能显著提升查询性能。