Question about query performance with post-aggregations

Hi, list.

I’m curious about how some post-aggregations are implemented. For instance, arithmetic post-aggregations may be implemented as javascript post-aggregation as bellow:

“postAggregations” : [
{ “type” : “javascript”,
“name” : “average_js”,
“fieldNames” : [“chars_added”, “count”],
“function” : “function(a,b) {return a/b; }”

“postAggregations” : [{
“type” : “arithmetic”,
“name” : “average_arit”,
“fn” : “/”,
“fields” : [
{“type” : “fieldAccess”, “fieldName” : “chars_added”},
{“type” : “fieldAccess”, “fieldName” : “count”}

Is there some difference about the performance between these two kinds?

Hey Marcelo,

Generally the native options are faster than the javascript-based options. Usually people use the javascript-based options when there is no native option available. That being said – postaggregations are not usually the bottleneck for a query so it may not matter too much.

Hi, Gian.

Thank you for your clarification. I through that postaggregations like aritmethic were converted in javascript before execution, just because they are particular cases that we can implement in javascript postaggregations.