You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "xiong duan (Jira)" <ji...@apache.org> on 2022/04/27 01:18:00 UTC
[jira] [Created] (CALCITE-5117) Optimize the EXISTS sub-query by Metadata RowCount
xiong duan created CALCITE-5117:
-----------------------------------
Summary: 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
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)