Performance impact of using JS aggregate/postAggregate functions

Hello Community,

What are the potential performance impacts of using a JS aggregate function?

Essentially, I want to make some simple calculations like this (and more complicated ones):

“postAggregations”: [


“type”: “javascript”,

“name”: “view_depth_pct”,

“fieldNames”: [“view_depth_sum”, “video_count”],

“function”: “function(sum, count) { return (sum) ? (100 * view_depth_sum) / video_count : 0; }”




What are the potential impacts, beside the fact that we have to access multiple columns?

Thanks in advance…

  • Rafael

In general the javascript stuff in Druid is much slower than the pure-java stuff.

A good use case for javascript stuff is for things which cannot be solved using the java items or java extensions until such a time that the java ones can be created.

In your case I think you can use a post aggregate where you multiply the longSum of depth_sum by 100 then divide by the longSum of video_count

Hi Rafael,

For post-aggregations the performance difference should not matter as much as for aggregations.
Post-aggregations are not evaluated as frequently during the execution of a query.