-
1. Re: Optimization is not applied to inline view if the translator does not support inline views?
shawkins Aug 4, 2014 11:42 AM (in response to sanjeev.gour)More than likely we are not checking across a union for this optimization.
-
2. Re: Optimization is not applied to inline view if the translator does not support inline views?
sanjeev.gour Aug 4, 2014 12:37 PM (in response to shawkins)Thanks Steve. Do you think a JIRA ticket should be created for this?
-
3. Re: Optimization is not applied to inline view if the translator does not support inline views?
markaddleman Aug 4, 2014 12:39 PM (in response to sanjeev.gour)[TEIID-3062] Apply LIMIT 1 optimization for DISTINCT in UNION situations - JBoss Issue Tracker
I beat you to it, Sanjeev (I figured you'd be asleep)
-
4. Re: Optimization is not applied to inline view if the translator does not support inline views?
shawkins Aug 4, 2014 2:47 PM (in response to markaddleman)While later versions are still not expressly checking the union case, as long as there is a partitioning (the differing constant values in each branch), then we'll arrive at the desired plan.
-
5. Re: Optimization is not applied to inline view if the translator does not support inline views?
markaddleman Aug 4, 2014 3:36 PM (in response to shawkins)We're not using a partitioned union in this case. Should we file an enhancement request?
-
6. Re: Optimization is not applied to inline view if the translator does not support inline views?
shawkins Aug 4, 2014 4:11 PM (in response to markaddleman)In the example given the union is partitioned over datamart_name. Just retest your scenario against a later version to confirm if you get the plan that you expect.
-
7. Re: Optimization is not applied to inline view if the translator does not support inline views?
sanjeev.gour Aug 5, 2014 9:06 AM (in response to shawkins)We tried with 8.7 but the limit it still not applied. One more thing we observed is that the behavior is particularly affected by a constant in the outer query. If the outer query doesn't have a constant then the limit is pushed. Keeping the constants same in the queries involved in the UNIONs does not seem to affect the behavior.
This will push the limit-
SELECT DISTINCT DATAMART_NAME AS c_9 AS c_10 FROM (SELECT datamart_name FROM
(
SELECT 'DATACOM Datamart' AS DATAMART_NAME FROM SECURITY_DM_DATACOM_DEV_R140_CA31_CMGRD1.VIEWOBJACCESS
UNION ALL
SELECT 'DB2 D91A Datamart' AS DATAMART_NAME FROM SECURITY_DM_DB2_D91APTIB_CMGRD1.VIEWOBJACCESS
) AS t
) a
This won't-
SELECT DISTINCT DATAMART_NAME AS c_9, '_constant_' AS c_10 FROM (SELECT datamart_name FROM
(
SELECT 'DATACOM Datamart' AS DATAMART_NAME FROM SECURITY_DM_DATACOM_DEV_R140_CA31_CMGRD1.VIEWOBJACCESS
UNION ALL
SELECT 'DB2 D91A Datamart' AS DATAMART_NAME FROM SECURITY_DM_DB2_D91APTIB_CMGRD1.VIEWOBJACCESS
) AS t
) a
-
8. Re: Optimization is not applied to inline view if the translator does not support inline views?
shawkins Aug 5, 2014 9:10 AM (in response to sanjeev.gour)The first case is the simple partitioning that I am referring to. The second case was logged as a different issue - [TEIID-3063] Push down DISTINCT with select expression in the query and the datasource doesn't support select expression…
-
9. Re: Optimization is not applied to inline view if the translator does not support inline views?
shawkins Aug 6, 2014 8:50 AM (in response to shawkins)I went ahead and reopened TEIID-3062 and addressed it along with TEIID-3063.