Hi.
I execute a aggregation query which matches only less than 100 documents over the index which has 200m documents with 10 shards (1 replica)
Most of the time, the query is executed very quickly (less than 20ms) but sometimes it takes 300ms ~ a couple of seconds. I cannot figure out which one is a problem.
Before profiling, I thought Disk I/O would be the problem. But It turned out that BucketCollector
took long time at that time.
As you can see below, all queries are ended within 10ms, but BucketCollector
was took 286ms (As I said, Collector would collect only less than 100 documents)
My Questions
- The result of profiling is trustworthy? (sometimes
time
is greater thantook
) - If
BucketCollect
is the root cause of lag, what can I do for improving performance? I hope you can give me recommendations.
Thanks in advanced.
"profile": {
"shards": [
{
"id": "[...][index-name][4]",
"searches": [
{
"query": [
{
"query_type": "ConstantScoreQuery",
"lucene": "ConstantScore(+field1:keyword1 +field2:keyword2 +(+*:* -field3:) +ConstantScore(_field_names:field3) +(+*:* -field4) +ConstantScore(_field_names:field4))",
"time": "8.855492000ms",
...
},
"children": [
{
"query_type": "BooleanQuery",
"lucene": "+field1:keyword1 +field2:keyword2 +(+*:* -field3:) +ConstantScore(_field_names:field3) +(+*:* -field4) +ConstantScore(_field_names:field4)",
"time": "6.159800000ms",
...
"children": [
{
"query_type": "TermQuery",
"lucene": "field1:keyword1",
"time": "0.3522230000ms",
...
},
{
"query_type": "TermQuery",
"lucene": "field2:keyword2",
"time": "0.8661380000ms",
...
},
{
"query_type": "BooleanQuery",
"lucene": "+*:* -field3:",
"time": "0.5188010000ms",
...
"children": [
{
"query_type": "MatchAllDocsQuery",
"lucene": "*:*",
"time": "0.0008740000000ms",
...
},
{
"query_type": "TermQuery",
"lucene": "field3:",
"time": "0.1813230000ms",
...
}
]
},
...
...
]
}
]
}
],
"rewrite_time": 22178,
"collector": [
{
"name": "MultiCollector",
"reason": "search_multi",
"time": "286.5113430ms",
"children": [
{
"name": "TotalHitCountCollector",
"reason": "search_count",
"time": "0.01601100000ms"
},
{
"name": "BucketCollector: [[agg1, agg1_cnt]]",
"reason": "aggregation",
"time": "286.4594230ms"
}
]
}
]
}
]
}