# Why is docvalue\_fields much faster than source.includes?

**URL:** https://discuss.elastic.co/t/why-is-docvalue-fields-much-faster-than-source-includes/225972
**Category:** Elasticsearch
**Created:** [April 1, 2020, 5:18am UTC](https://discuss.elastic.co/t/why-is-docvalue-fields-much-faster-than-source-includes/225972 "2020-04-01T05:18:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![G-K-Patel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/g-k-patel/32/53143_2.png) [@G-K-Patel](https://discuss.elastic.co/u/G-K-Patel)
#### Post date: [April 1, 2020, 5:18am UTC](https://discuss.elastic.co/t/why-is-docvalue-fields-much-faster-than-source-includes/225972/1 "2020-04-01T05:18:21Z")

</div>

Hi Elastic Community,

I have seen drastic change in retrival speed when using docvalue\_fields instead of source.includes, as speficied in [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#nested-inner-hits-source).

Can someone explain to me what is the different between the two ? What disadvantages can docvalue\_fields bring that might not be clear at first (one disadvantage is the storgare space, as mentioned in [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html#doc-values).

A bigger question for me is, why do we have two settings to achieve the same goal ? What are the advantages and disadvantages of both ? Why is the same data stored twice in two differnent format ?

Thanks for reading and also for the reply.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 1, 2020, 5:31am UTC](https://discuss.elastic.co/t/why-is-docvalue-fields-much-faster-than-source-includes/225972/2 "2020-04-01T05:31:14Z")

</div>

As far as I know do value fields are stored individually and very efficient to retrieve while getting data from source requires the full document to be loaded and parsed before data can be accessed. The larger your documents the larger the expected difference in performance.

---

<div class="post-metadata">

### Author: ![G-K-Patel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/g-k-patel/32/53143_2.png) [@G-K-Patel](https://discuss.elastic.co/u/G-K-Patel)
#### Post date: [April 1, 2020, 8:44am UTC](https://discuss.elastic.co/t/why-is-docvalue-fields-much-faster-than-source-includes/225972/3 "2020-04-01T08:44:12Z")

</div>

Hi @Christian_Dahlqvist ,

Thanks for the reply, it clarifies a lot. But I still fail to understand one thing, why is the data stored sperately. Form your reply, I understand that the delay arises becaus the data is processed differently (i.e. processing overhead is higher in source.includes), but then why does disabeling doc\_values help us save space (or in other words, why does doc\_values occupy more space when enabled); as mentioned [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html#doc-values).

Moreover, I have one more question on the same topic:  
When I ran the example give [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#nested-inner-hits-source), I saw something wierd in the output (see below), namely the retrived values are list/arrays containing the original value. Do you know why this would be the case ? (importantly, I would like to know, is there a case when more than one values could appear, I am using ES 6.8)

```
"hits" : {
"total" : 1,
"max_score" : 1.0444683,
"hits" : [
  {
    "_index" : "test",
    "_type" : "doc",
    "_id" : "1",
    "_score" : 1.0444683,
    "_source" : {
      "title" : "Test title",
      "comments" : [
        {
          "author" : "kimchy",
          "text" : "comment text"
        },
        {
          "author" : "nik9000",
          "text" : "words words words"
        }
      ]
    },
    "inner_hits" : {
      "comments" : {
        "hits" : {
          "total" : 1,
          "max_score" : 1.0444683,
          "hits" : [
            {
              "_index" : "test",
              "_type" : "doc",
              "_id" : "1",
              "_nested" : {
                "field" : "comments",
                "offset" : 1
              },
              "_score" : 1.0444683,
              "fields" : {
                "comments.text.keyword" : [
                  "words words words" <- WHY IS THIS A LIST/ARRAY ? 
                ]
              }
            }
          ]
        }
      }
    }
  }
]

```

}

---

<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: [April 29, 2020, 8:44am UTC](https://discuss.elastic.co/t/why-is-docvalue-fields-much-faster-than-source-includes/225972/4 "2020-04-29T08:44:17Z")

</div>

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