[MDEV-13162] Condition pushdown into derived tables on the inner sides of outer joins Created: 2017-06-23  Updated: 2021-10-25

Status: Open
Project: MariaDB Server
Component/s: Optimizer
Fix Version/s: None

Type: Task Priority: Major
Reporter: Sergei Petrunia Assignee: Igor Babaev
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-12845 subquery with group by not using index Closed

 Description   

Consider an example:

create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
create table t21 (a int, b int, c int);
insert into t21 select a,a,a from ten;
create table t22 (a int, b int, c int);
insert into t22 select a,a,a from ten;

explain format=json
select *
from
  t21 LEFT JOIN
  (select a,b, COUNT(*) as CNT from t22 group by a,b) TBL
  ON (t21.a=TBL.a AND TBL.a<5);

here, "TBL.a<5" can be pushed down into the subquery, but it is not. EXPLAIN EXTENDED shows:

  "query_block": {
    "select_id": 1,
    "const_condition": "1",
    "table": {
      "table_name": "t21",
      "access_type": "ALL",
      "rows": 10,
      "filtered": 100
    },
    "table": {
      "table_name": "<derived2>",
      "access_type": "ref",
      "possible_keys": ["key0"],
      "key": "key0",
      "key_length": "5",
      "used_key_parts": ["a"],
      "ref": ["test.t21.a"],
      "rows": 2,
      "filtered": 100,
      "attached_condition": "trigcond(trigcond(t21.a < 5 and t21.a is not null))",
      "materialized": {
        "query_block": {
          "select_id": 2,
          "filesort": {
            "sort_key": "t22.a, t22.b",
            "temporary_table": {
              "table": {
                "table_name": "t22",
                "access_type": "ALL",
                "rows": 10,
                "filtered": 100
              }
            }
          }
        }
      }
    }



 Comments   
Comment by Sergei Petrunia [ 2017-06-23 ]

This is not directly related to MDEV-12845 but is in the same feature.

Comment by Igor Babaev [ 2017-06-26 ]

Sergei,
The project of mdev-9197 did not intend to push from ON expressions.
So you'd better open a new task instead of this 'bug'.

Comment by Sergei Petrunia [ 2017-06-27 ]

Ok, converted this into a task.

Generated at Thu Feb 08 08:03:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.