[MCOL-3578] rank() works, max() window function does not in otherwise identical query Created: 2019-10-28  Updated: 2023-07-02  Resolved: 2023-07-02

Status: Closed
Project: MariaDB ColumnStore
Component/s: N/A
Affects Version/s: 1.2.5
Fix Version/s: Icebox

Type: Task Priority: Major
Reporter: Patrick LeBlanc (Inactive) Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Environment:

ubuntu 18 LTS. 1UM, 2 PMs.



 Description   

Greg & I are diagnosing remaining scalability issues with the denormalized 50gb dbt3 data set, ran into a bug, where the max() window function + a group by of 500k keys will cause an infinite loop in a single thread. It is based query 15 in the dbt3 set. We've simplified it (and made it nonsensical) to make it clear.

I assume it is independent of the size of the data or the fact it is denormalized, so it is likely reproducible with the standard dbt3 load. Replace the denorm table with supplier.

A version of the query that works:
select * from (
select
rank() over (order by sum(l_extendedprice)) rank_total_revenue
from denorm
where
l_shipdate >= '1994-11-01'
and l_shipdate < date_add('1994-11-01', interval 90 day)
group by s_suppkey
) dq
;

Version that doesn't work
select * from (
select
max(sum(l_extendedprice)) over() as max_total_revenue
from denorm
where
l_shipdate >= '1994-11-01'
and l_shipdate < date_add('1994-11-01', interval 90 day)
group by s_suppkey
) dq
;



 Comments   
Comment by David Hall (Inactive) [ 2019-11-11 ]

The query does finish, just after a very long time.
The default we use for the FRAME is BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. This runs a double (triple) loop through the code.
We need to change the default to BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, which gives the exact same answer but much quicker, as the inside loops are optimized out. This is the default used by other RDBMS's.

Comment by Todd Stoffel (Inactive) [ 2023-07-02 ]

The "create date" on this ticket is pre-convergence with MariaDB server. If the issue still exists in a modern version of the engine/plugin please submit a new ticket.

Generated at Thu Feb 08 02:43:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.