[MDEV-10855] Window functions: condition pushdown through the PARTITION BY clause Created: 2016-09-21  Updated: 2017-11-13  Resolved: 2017-11-13

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

Type: Task Priority: Major
Reporter: Sergei Petrunia Assignee: Igor Babaev
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-13385 Window Functions: Push condition into... Closed
Relates
relates to MDEV-6115 window functions as in the SQL standard Closed

 Description   

MDEV-9197 adds support for pushdown of conditions into mergeable VIEWs (or derived tables).

Suppose the child query

  • uses a window function
  • the window function has a PARTITION BY col1 clause

Then, the condition on col1 can be pushed down through the window function.

Example:

select * from (
  select
    name,
    rank() over (partition by dept
                 order by incidents desc) as R
  from
    staff
) as TBL
where dept='Support'

Here, current execution will compute incidents across all departments. However, we are only interested in dept='Support'. PARTITION BY dept allows pushing the dept='Support' condition to the inner query's WHERE condition.

Initial mention of this possible feature:
https://www.percona.com/live/data-performance-conference-2016/sessions/window-functions-mariadb , slide #66.

CC: cvicentiu, igor, sanja.



 Comments   
Comment by Igor Babaev [ 2017-08-15 ]

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

Comment by Igor Babaev [ 2017-11-13 ]

The code to support the optimization required by the task was pushed into 10.3
(commit 61bbabb202ddada20dc39970734ce93b0709de0d)

Generated at Thu Feb 08 07:45:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.