# Performance when fetching ids for large result set

**URL:** <https://discuss.elastic.co/t/performance-when-fetching-ids-for-large-result-set/33350>\
**Category:** Elasticsearch\
**Created:** [October 30, 2015, 9:08am UTC](https://discuss.elastic.co/t/performance-when-fetching-ids-for-large-result-set/33350 "2015-10-30T09:08:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kshitij\_Gupta1](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kshitij\_Gupta1](https://discuss.elastic.co/u/Kshitij_Gupta1)\
**Post date:** [October 30, 2015, 9:08am UTC](https://discuss.elastic.co/t/performance-when-fetching-ids-for-large-result-set/33350/1 "2015-10-30T09:08:53Z")

</div>

Hi,

Let's say I am running a query (only with filters) which has 100,000 matching documents.

When I run the query with search\_type=count, it runs pretty quickly (~10 ms) which implies that the filtering is quite fast.

```
GET /denorm/_search?search_type=count
{
  "query": {
    "filtered": {
      "filter": {
        some filter here
        }
      }
    }
  }
}

```

But when I run the same query and fetch the ids of the matching results (not fetching any fields), the query is quite slow (~2 s)

```
GET /denorm/_search
    {
      "size": 100000
      "query": {
        "filtered": {
          "filter": {
            some filter here
            }
          }
        }
      },
     "fields": []
    }

```

I would like to understand the reason for this and if there is any way to speed up the fetching of ids.

Is the time taken in mapping lucene docids to \_uid? How does that work? Is there some cache to speed this up? Is the fielddata cache used in this?

I am using 1.4.2 right now. Also note that I am using my app specific ids.

Thanks,  
Kshitij

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 30, 2015, 5:58pm UTC](https://discuss.elastic.co/t/performance-when-fetching-ids-for-large-result-set/33350/2 "2015-10-30T17:58:54Z")

</div>

Are you changing the size parameter to return more than the default?

Ivan

---

<div class="post-metadata">

**Author:** ![Kshitij\_Gupta1](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kshitij\_Gupta1](https://discuss.elastic.co/u/Kshitij_Gupta1)\
**Post date:** [October 31, 2015, 3:58am UTC](https://discuss.elastic.co/t/performance-when-fetching-ids-for-large-result-set/33350/3 "2015-10-31T03:58:06Z")

</div>

Yes. I need ids for all the matching documents.

```
GET /denorm/_search
    {
      "size": 100000
      "query": {
        "filtered": {
          "filter": {
            some filter here
            }
          }
        }
      },
     "fields": []
    }

```

Thanks,  
Kshitij

---

<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:** [July 5, 2017, 11:41pm UTC](https://discuss.elastic.co/t/performance-when-fetching-ids-for-large-result-set/33350/4 "2017-07-05T23:41:35Z")

</div>


