Hi,
I have a performance problem related to documents that have many documents on nested relation.
We've recently realized that we have some slow queries that depends on the data itself and not the query.
Ex: I query for all items by a simple relation field:
GET index/_search
{"from":0,"size":10,
"query":{
"bool":{
"filter":[
{"term":{
"retailer.id":{"value":123,"boost":1.0}
}
}],
"adjust_pure_negative":true,"boost":1.0
}
},"_source":{"includes":["id"],"excludes":["nested_relations"]}
}
and it takes 5 ms, but I do the same with a doc that has 6200 nested objects and it takes 240ms.
I tried excluding fields, returning only id, it's more or less the same.
In the query is nothing related to that nested object relation, no filtering no ordering, just the documents existing. If I remove the nested objects, then it goes well for the same doc.
I've tried also denormalizing and duplicating content, as create every root doc with every object on the nested field, so the data of the root doc is repeated n times per object relation and then I do aggs. This way performance is a lot greater but it complicates the query and pagination can't be done.
So the question is, there is a limitation of size for performance related to nested objects?
Why is affected on queries that do not use this relation at all?
The mapping index:
PUT test_index
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 1
}
},
"mappings": {
"doc": {
"dynamic": "strict",
"properties": {
"id": {"type": "long"},
"name": {"type": "text"},
"retailer": {
"type": "object",
"properties": {
"id": {"type": "long"}
}
},
"stores": {
"type": "nested",
"properties": {
"id": {"type": "long"},
"normalized_name": {"type": "keyword"},
"area": {"type": "geo_shape", "tree": "quadtree", "precision": "2km"},
"location": {"type": "geo_point"},
"retailer_id": {"type": "long"},
"address": {
"type": "object",
"properties": {
"location": {"type": "keyword"},
"locality": {"type": "keyword"},
"post_code": {"type":"keyword"},
"municipality_normalized_name": {"type":"keyword"}
}
},
"time_zone_difference": {"type": "integer"},
"opening_times": {
"type": "nested",
"properties": {
"day_of_week": {"type":"integer"},
"ini_hour": {"type":"integer"},
"ini_minute": {"type":"integer"},
"end_hour": {"type":"integer"},
"end_minute": {"type":"integer"}
}
}
}
}
}
}
}
}
I'm using ES version 6.5.
Thank you