Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-1991

GROUP BY pushdown into subselect of UNIONs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 7.7
    • Query Engine
    • None

      If have a query of the form
      SELECT a FROM (
      SELECT a FROM (
      SELECT a FROM ds.t1
      ) u
      ) t GROUP BY a

      Teiid correctly optimizes the inner SELECT to SELECT 1 FROM ds.t1. However, if the inner subselect is a union:
      SELECT a FROM (
      SELECT a FROM (
      SELECT a FROM ds.t1 UNION
      SELECT a FROM ds.t2
      ) u
      ) t GROUP BY a

      Teiid does not optimize to
      SELECT 1 FROM ds.t1 UNION
      SELECT 1 FROM ds.t2
      as I would expect.

      See attached plan

        1. efficient_rewrite.txt
          10 kB
        2. plan.txt
          61 kB
        3. plan.txt
          6 kB
        4. simplified_plan.txt
          11 kB

            rhn-engineering-shawkins Steven Hawkins
            markaddleman_jira Mark Addleman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: