Slow Terms Aggregation


#1

Hi, I hava a problem with es query and aggregation. All es record count is about 0.1 billion, before adding a terms aggregation, my query is fast, only cost 75ms and all hit count is 105. But after adding a aggregation, like this one:
{
"query": {
...
},
"aggs": {
"index": {
"terms": {
"field": "index"
}
}
}
}
this query will cost 20 second!
My question is: my query result count is only 105, why the aggregation is so slow?
Thanks for any reply!


(Mark Harwood) #2

When we gather terms in results we can either gather the full-strings in memory or what we call a "global ordinal" which is much more compact. The ordinal is a number which is given to every unique string and it is this process of determining the strings->numbers lookup that can be expensive on an index that is still constantly being written to. So given the low number of search results maybe you'd be better served by using raw strings rather than the ordinals which is the map execution hint.

What is the number of unique terms for the field in question, out of interest?


#3

When I use map execution hint, query is faster than before, thanks.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.