apache / druid

Apache Druid: a high performance real-time analytics database.

Home Page:https://druid.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Window functions on MSQ for high and low cardinality data

somu-imply opened this issue · comments

At this moment, window functions in MSQ rely on materializing the data with the same partition into a rows and columns, process them and output to a frame. In case of low cardinality data (where a single partition has few distinct group and each group has an enormous amount of values) this can lead to running out of memory resources. One solution for this would be to redesign window functions in MSQ by not materializing the data and make multiple passes over the data. Most of the window operations like SUM(), RANK(), RANGE() etc. can be made with 2 passes of the data. We might think to reimplement them in the MSQ way so that we do not have to materialize so much data.

Similarly for data with high cardinality (large number of distinct groups for a column, each with small number of rows for each distinct value), at this moment we add a single group to a frame. This would end up creating a large number of frames. We can get past this by creating a fixed size frame and keep adding to the pending frame. The sorter will process the frames and make sure the data with the correct key reaches the correct processor

Base PR : #15470