You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2022/04/28 02:42:00 UTC
[jira] [Resolved] (CALCITE-5117) Optimize the EXISTS sub-query by Metadata RowCount
[ https://issues.apache.org/jira/browse/CALCITE-5117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
xiong duan resolved CALCITE-5117.
---------------------------------
Resolution: Fixed
> Optimize the EXISTS sub-query by Metadata RowCount
> --------------------------------------------------
>
> Key: CALCITE-5117
> URL: https://issues.apache.org/jira/browse/CALCITE-5117
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.30.0
> Reporter: xiong duan
> Assignee: xiong duan
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.31.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> As same as the UNIQUE sub-query, before we convert the sub-query to RelNode. we use the Metadata to optimize it.
> EXISTS sub-query, If the sub-query is guaranteed to produce at least one row, just return TRUE. If the sub-query is guaranteed to produce no row, just return FALSE.
> For example:
> {code:java}
> select *
> from dept as d
> where EXISTS (select count(*) from emp e where d.deptno = e.deptno){code}
> We can optimize it to:
> {code:java}
> EnumerableTableScan(table=[[scott, DEPT]]){code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)