[MDEV-13385] Window Functions: Push condition into inner query Created: 2017-07-26  Updated: 2020-08-25  Resolved: 2017-07-28

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Andrii Nikitin (Inactive) Assignee: Sergei Petrunia
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-10855 Window functions: condition pushdown ... Closed
Relates
relates to MDEV-13389 Optimization for equi-joins of derive... Closed

 Description   

At the moment optimizer does not push condition into Window function in SELECT part of inner query:

create or replace table t1 (a int, b int, c int, index(a, b, c));
create or replace table t2 (a int, b int, c int, index(a, b, c));
 
insert into t1 select seq, seq, seq from seq_1_to_100000;
insert into t2 select seq, seq, seq from seq_1_to_100000;
 
explain
select * from 
(
select t1.a a, t2.b b, t2.c, sum(t2.c) over ( partition by a,b,c )
from t1 join t2
where 
t1.a=t2.a and t1.b=t2.b
)
v1 where (a, b, c) = (50000,50000,50000);

 
+------+-------------+------------+-------+---------------+------+---------+-------------------------------------+--------+-------------------------------------------+
| id   | select_type | table      | type  | possible_keys | key  | key_len | ref                                 | rows   | Extra                                     |
+------+-------------+------------+-------+---------------+------+---------+-------------------------------------+--------+-------------------------------------------+
|    1 | PRIMARY     | <derived2> | ALL   | NULL          | NULL | NULL    | NULL                                | 100000 | Using where                               |
|    2 | DERIVED     | t1         | index | a             | a    | 15      | NULL                                | 100000 | Using where; Using index; Using temporary |
|    2 | DERIVED     | t2         | ref   | a             | a    | 10      | tdsdbsgowner.t1.a,tdsdbsgowner.t1.b |      1 | Using index                               |
+------+-------------+------------+-------+---------------+------+---------+-------------------------------------+--------+-------------------------------------------+

So optimizer is processing all rows for inner query instead of using WHERE condition from outer query



 Comments   
Comment by Sergei Petrunia [ 2017-07-28 ]

I'm wondering how exactly this should work. Is this the same as MDEV-10855 or some different kind of optimization?

Comment by Andrii Nikitin (Inactive) [ 2017-07-28 ]

Yes this looks like duplicate of MDEV-10855 . So closing accordingly. Sorry - it looks that I did check only existing bugs and somehow didn't notice this task.

Comment by Igor Babaev [ 2017-08-15 ]

The patch resolving this problem was pushed into bb-10.2-ext.

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