Hi,

Recently I've updated implementation of window functions to support RANGE,
expr PRECEDING/FOLLOWING, UNBOUNDED FOLLOWING [1].

Please let me know if you have any objections to getting it merged.

The implementation is optimized for the cases when lower bound stays intact
and the upper bound moves down: "unbounded preceding and current row" and
"unbounded preceding and unbounded following" cases.

For instance, count(*) over () is infinite times faster now as it computes
the aggregate only once, and then it just reuses the result.
In fact, count(non_nullable), row_number(), first_value(), and last_value()
are O(1): it's just index arithmetic to compute the value.

Range windows use binary search to find out the lower/upper bounds.

If the window becomes invalid (e.g. upper bound is less than lower bound),
it is assumed the window is empty (no exception).

Regular aggregate implementation was altered a bit: if the user-defined
function provides non-static init/add/result methods, then only one
instance is created per grouping key (init, add, and result methods are
invoked on the same object instance).

1: https://github.com/julianhyde/optiq/pull/293

-- 
Regards,
Vladimir Sitnikov

Reply via email to