Story Details

  • The missing tier for query compilers

    Posted: 2025-02-10 03:36:05

    The blog post argues for an intermediate representation (IR) layer in query compilers between the logical plan and the physical plan, called the "relational algebra IR." This layer would represent queries in a standardized, relational algebra form, enabling greater portability and reusability of optimization rules across different physical execution engines. Currently, optimization logic is often tightly coupled to specific physical plans, making it difficult to adapt to new engines or hardware. By introducing this standardized relational algebra IR, query compilers can achieve better modularity and extensibility, simplifying development and allowing for easier experimentation with new optimization strategies without needing to rewrite code for each backend. This ultimately leads to more efficient query execution across diverse environments.

    Summary of Comments ( 8 )
    https://news.ycombinator.com/item?id=42996656

    HN commenters generally agree with the author's premise that a middle tier is missing in query compilers, sitting between logical optimization and physical optimization. This tier would handle "cross-physical plan" optimizations, allowing for better cost-based decisions that consider different physical plan choices holistically rather than sequentially. Some discuss the challenges in implementing this, particularly the explosion of search space and the difficulty in accurately costing plans. Others offer specific examples where such a tier would be beneficial, such as selecting join algorithms based on data distribution or optimizing for specific hardware like GPUs. A few commenters mention existing systems that implement similar concepts, though not necessarily as a distinct tier, suggesting the idea is already being explored in practice. Some debate the practicality of the proposed solution, suggesting alternative approaches like adaptive query execution or learned optimizers.