EventTime大于2014-03-19 00:00:00的数据量有600W,需要通过OS和Sex两个字段聚合,即select count(1) from test_index group by OS, Sex。 用Composite Aggs和Multi Terms Aggs性能差异巨大,profiler看到Multi Terms Aggs聚合的90%的耗时都在aggs阶段的collec。 有大神知道为什么Multi Term Aggs比Composite Aggs慢这么多吗?
Composite Aggs耗时:1187ms
Multi Terms Aggs耗时:16359ms
总的bucket都是150个,也就是2种查询方式都是查出全部的bucket了,但速度相差10倍,有大神解解答下吗?
Composite Aggs查询语句
Composite Aggs耗时:1187ms
Multi Terms Aggs耗时:16359ms
总的bucket都是150个,也就是2种查询方式都是查出全部的bucket了,但速度相差10倍,有大神解解答下吗?
Composite Aggs查询语句
POST test_index/_search
{
"size": 0,
"query": {
"bool": {
"filter": [
{"range": {
"EventTime": {"gte":"2014-03-19 00:00:00"}
}}
]}},
"aggs": {
"test": {
"composite" : {
"size": 200,
"sources" : [
{ "OS": { "terms": {"field": "OS" } } },
{ "Sex": { "terms": {"field": "Sex" } } }
]
}
}
}
}
Multi Terms Aggs查询语句POST test_index/_search
{
"size": 0,
"query": {
"bool": {
"filter": [
{"range": {
"EventTime": {"gte":"2014-03-19 00:00:00"}
}}
]}},
"aggs": {
"test": {
"multi_terms": {
"size":200
"terms": [{
"field": "OS"
}, {
"field": "Sex"
}]
}
}
}
}
2 个回复
caster_QL
赞同来自:
https://www.elastic.co/guide/e ... .html
The multi_term aggregations are the most useful when you need to sort by a number of document or a metric aggregation on a composite key and get top N results. If sorting is not required and all values are expected to be retrieved using nested terms aggregation or composite aggregations will be a faster and more memory efficient solution.
caster_QL
赞同来自: