[MDEV-15398] Poor performance in query with filtered rank Created: 2018-02-23  Updated: 2018-08-15  Resolved: 2018-08-15

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Fix Version/s: 10.3.4

Type: Task Priority: Major
Reporter: Tadas Balaišis Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None


 Description   

Can not achieve good performance in query with filtered columns outside of inner part with RANK() function. These columns participate in "partition by" expression of RANK(), bet filter isn't pushed down. Same functionality in Oracle works fine.

Short example.

Good performance:

select ml_id, nr, da
,rank() over (partition by ml_id, nr, da order by nr) r
from ml, iger, days
where ml_id = 4 and nr = 1 and da = date(now())

Bad performance (desired query):

select * from (
select ml_id, nr, da
,rank() over (partition by ml_id, nr, da order by nr) r
from ml, iger, days
) a where ml_id = 4 and nr = 1 and da = date(now())

Plan:

1 PRIMARY <derived2> ALL \N \N \N \N 22991097024000 Using where
2 DERIVED ml index \N ml_aggf_i 1 \N 12150 Using index; Using temporary
2 DERIVED days index \N PRIMARY 3 \N 21760 Using index; Using join buffer (flat, BNL join)
2 DERIVED iger index \N PRIMARY 3 \N 86961 Using index; Using join buffer (incremental, BNL join)

What could be done to improve?



 Comments   
Comment by Tadas Balaišis [ 2018-02-24 ]

Upgraded software from 10.2.12 to 10.3.4. Now it works fine. Thanks.

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