Hi,
When writing SQL with GROUP BY, quite often I want to get value for some column from any row.
For example, I am looking to get SQL that was executed most often in last several hours (by digest), and see one SQL as sample:
select count() cnt, min(request) req
from dc_requests_issued
where time > current_timestamp - 0.1
and request_type = 'QUERY'
group by digest
order by count() desc;
I am using MIN as it is GROUP BY.
I actually do not care what rows will be picked by MIN function, I would be fine with ANY. MIN function consume CPU resources, and taking MIN from very long strings like SQL is resource - intensive.
Is there a way to ask Vertica to return ANY row value in GROUP BY?
I can easily implement this ANY function as c++ UDX aggregate (UDAFs to be exact). Just pick up first value in partition, save it, ignore rest rows, and return saved value at the end. Would be trivial implementation.
Thank you