# Structure of document affect speed?

**URL:** <https://discuss.elastic.co/t/structure-of-document-affect-speed/315897>\
**Category:** Elasticsearch\
**Created:** [October 5, 2022, 3:50pm UTC](https://discuss.elastic.co/t/structure-of-document-affect-speed/315897 "2022-10-05T15:50:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaVa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mava/32/100571_2.png) [@MaVa](https://discuss.elastic.co/u/MaVa)\
**Post date:** [October 5, 2022, 3:50pm UTC](https://discuss.elastic.co/t/structure-of-document-affect-speed/315897/1 "2022-10-05T15:50:07Z")

</div>

I have a question out of curiosity. Does the structure of the document have any effect on the indexing and searching speed in an index?

Would e.g.

```auto
"user": {
       "id":"123",
       "first_name":"John",
       "last_name":"Doe"
}

```

take longer time than

```auto
{
"user_id":"123",
"user_first_name":"John",
"user_last_name":"Doe"
}

```

?

In the example case I know the potential difference be miniscule, but imagine you have millions of docs with loads of nested data, would it have anything to say?

---

<div class="post-metadata">

**Author:** ![EmaysHRT](https://avatars.discourse-cdn.com/v4/letter/e/8c91f0/32.png) [@EmaysHRT](https://discuss.elastic.co/u/EmaysHRT)\
**Post date:** [October 6, 2022, 4:23pm UTC](https://discuss.elastic.co/t/structure-of-document-affect-speed/315897/2 "2022-10-06T16:23:10Z")

</div>

Unless you set up custom mappings using [the `nested` field type](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html), the internal representation is going to be flattened to this:

```auto
{
  "user.id": "123",
  "user.first_name": "John",
  "user.last_name": "Doe"
}

```

It's functionally equivalent to the document on the bottom, so there should be no difference in performance.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 3, 2022, 4:24pm UTC](https://discuss.elastic.co/t/structure-of-document-affect-speed/315897/3 "2022-11-03T16:24:03Z")

</div>

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