[teiid-issues] [JBoss JIRA] (TEIID-1991) GROUP BY pushdown into subselect of UNIONs
Mark Addleman (JIRA)
jira-events at lists.jboss.org
Wed Apr 4 12:43:47 EDT 2012
[ https://issues.jboss.org/browse/TEIID-1991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12681790#comment-12681790 ]
Mark Addleman commented on TEIID-1991:
--------------------------------------
When there is a single SELECT in the inline view
SELECT u.datamart_name
FROM (
SELECT 'abc' AS DATAMART_NAME, a.evttypecode
FROM SECURITY_DM_DATACOM_DEV_R140_XE59_CMGRD1.ADMACCOUNT AS a
) AS u
GROUP BY u.datamart_name
It appears that Teiid understands it only needs to know if there is *any* data coming from the ADMACCOUNT table, so it issues SELECT 1 FROM SECURITY_DM_DATACOM_DEV_R140_XE59_CMGRD1.ADMACCOUNT instead.
I would expect Teiid to apply the same optimization if the inline view contained a UNION.
> GROUP BY pushdown into subselect of UNIONs
> ------------------------------------------
>
> Key: TEIID-1991
> URL: https://issues.jboss.org/browse/TEIID-1991
> Project: Teiid
> Issue Type: Bug
> Components: Query Engine
> Affects Versions: 7.7
> Reporter: Mark Addleman
> Assignee: Steven Hawkins
> Attachments: efficient_rewrite.txt, plan.txt, plan.txt, simplified_plan.txt
>
>
> 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
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the teiid-issues
mailing list