You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Zhuravkov (Jira)" <ji...@apache.org> on 2024/01/29 08:23:00 UTC

[jira] [Created] (IGNITE-21372) Sql. Do not execute queries that guaranteed to return none results.

Maksim Zhuravkov created IGNITE-21372:
-----------------------------------------

             Summary: Sql. Do not execute queries that guaranteed to return none results.
                 Key: IGNITE-21372
                 URL: https://issues.apache.org/jira/browse/IGNITE-21372
             Project: Ignite
          Issue Type: Improvement
          Components: sql
    Affects Versions: 3.0.0-beta2
            Reporter: Maksim Zhuravkov


{code:java}
sql("CREATE TABLE t2 (id INTEGER PRIMARY KEY, val INTEGER)");

// Query that never returns a result:
sql("SELECT * FROM t2 WHERE id IS NULL");

// Plan
IgniteExchange(distribution=[single]): rowcount = 2500.0, cumulative cost = IgniteCost [rowCount=12500.0, cpu=42500.0, memory=0.0, io=0.0, network=20000.0], id = 28
  IgniteTableScan(table=[[PUBLIC, T2]], tableId=[8], *filters=[false]*, requiredColumns=[{0, 1}]): rowcount = 2500.0, cumulative cost = IgniteCost [rowCount=10000.0, cpu=40000.0, memory=0.0, io=0.0, network=0.0], id = 25

{code}
Although the optimizer is able deduce that `id is NULL` is always false, since id is not nullable, and converted a predicate FALSE, the execution engine still runs such a query.

It is possible reduce plans that are guaranteed to produce no results to some form of an empty plan, so that the execution engine won't run them and return an empty cursor instead.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)