Hi,
Different operations in script field lead to quite different performance. In my environment, the below query cost about 400ms.
GET es/_search
{
"size": 0,
"aggs": {
"by_cluster": {
"terms": {
"field": "Cluster",
"size": 10
},
"aggs": {
"by_user": {
"terms": {
"field": "User",
"size": 10
},
"aggs": {
"total_pend": {
"sum": {
"field": "Pend Time",
}
}
}
}
}
}
}
}
When I use script field which contains multiplication operation, the similar query cost about 1100ms.
GET es/_search
{
"size": 0,
"aggs": {
"by_cluster": {
"terms": {
"field": "Cluster",
"size": 10
},
"aggs": {
"by_user": {
"terms": {
"field": "User",
"size": 10
},
"aggs": {
"total_pend": {
"sum": {
"script": "doc['Pend Time'].value * 1000"
}
}
}
}
}
}
}
}
But when I use script field which contains division operation, the similar query cost about 6000ms which is too slow.
GET es/_search
{
"size": 0,
"aggs": {
"by_cluster": {
"terms": {
"field": "Cluster",
"size": 10
},
"aggs": {
"by_user": {
"terms": {
"field": "User",
"size": 10
},
"aggs": {
"total_pend": {
"sum": {
"script": "doc['Pend Time'].value / 1000",
}
}
}
}
}
}
}
}
I know the division operation costs much than multiplication operation. But I still wonder why the performance difference is so big.
Any way to improve the divison performance in script field?
Thanks for the help.
Ke