Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6891

Implement IntersectReorderRule

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.40.0
    • None

    Description

      physical plan not using this rule:

      EnumerableIntersect(all=[false]): rowcount = 4.0, cumulative cost = {40.0 rows, 42.0 cpu, 0.0 io}, id = 37
        EnumerableProject(DEPTNO=[$7]): rowcount = 14.0, cumulative cost = {28.0 rows, 29.0 cpu, 0.0 io}, id = 35
          EnumerableTableScan(table=[[CATALOG, SALES, EMP]]): rowcount = 14.0, cumulative cost = {14.0 rows, 15.0 cpu, 0.0 io}, id = 31
        EnumerableProject(DEPTNO=[$0]): rowcount = 4.0, cumulative cost = {8.0 rows, 9.0 cpu, 0.0 io}, id = 36
          EnumerableTableScan(table=[[CATALOG, SALES, DEPT]]): rowcount = 4.0, cumulative cost = {4.0 rows, 5.0 cpu, 0.0 io}, id = 34
      

      physical plan using this rule:

      EnumerableIntersect(all=[false]): rowcount = 4.0, cumulative cost = {40.0 rows, 42.0 cpu, 0.0 io}, id = 39
        EnumerableProject(DEPTNO=[$0]): rowcount = 4.0, cumulative cost = {8.0 rows, 9.0 cpu, 0.0 io}, id = 37
          EnumerableTableScan(table=[[CATALOG, SALES, DEPT]]): rowcount = 4.0, cumulative cost = {4.0 rows, 5.0 cpu, 0.0 io}, id = 32
        EnumerableProject(DEPTNO=[$7]): rowcount = 14.0, cumulative cost = {28.0 rows, 29.0 cpu, 0.0 io}, id = 38
          EnumerableTableScan(table=[[CATALOG, SALES, EMP]]): rowcount = 14.0, cumulative cost = {14.0 rows, 15.0 cpu, 0.0 io}, id = 35
      

      This rule put smaller inputs first. This helps reduce the size of intermediate results.

      We can see the diffferent of DAG, I used volcanol planner and topdown mode.

      original

      used rule:

      Attachments

        1. image-2025-03-16-09-37-47-916.png
          136 kB
          Zhen Chen
        2. image-2025-03-16-09-38-41-654.png
          259 kB
          Zhen Chen
        3. image-2025-03-16-09-40-10-496.png
          274 kB
          Zhen Chen

        Issue Links

          Activity

            People

              jensen Zhen Chen
              jensen Zhen Chen
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: