# How do I reduce scroll response time?

**URL:** <https://discuss.elastic.co/t/how-do-i-reduce-scroll-response-time/9766>\
**Category:** Elasticsearch\
**Created:** [November 20, 2012, 3:20am UTC](https://discuss.elastic.co/t/how-do-i-reduce-scroll-response-time/9766 "2012-11-20T03:20:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan\_compton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_compton/32/2610_2.png) [@ryan\_compton](https://discuss.elastic.co/u/ryan_compton)\
**Post date:** [November 20, 2012, 3:20am UTC](https://discuss.elastic.co/t/how-do-i-reduce-scroll-response-time/9766/1 "2012-11-20T03:20:15Z")

</div>

I have a query returning ~200K hits from 7 different indices distributed  
across our cluster. I process my results as:

while (true) {  
scrollResp =  
client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new  
TimeValue(600000)).execute().actionGet();  
for (SearchHit hit : scrollResp.getHits()){  
//process hit}

//Break condition: No hits are returned  
if (scrollResp.hits().hits().length == 0) {  
break;  
}  
}

I'm noticing that the client.prepareSearchScroll line can hang for quite  
some time before returning the next set of search hits. This seems to get  
worse the longer I run the code for.

My setup for the search is:

SearchRequestBuilder searchBuilder = client.prepareSearch( index\_names )  
.setSearchType(SearchType.SCAN)  
.setScroll(new TimeValue(60000)) //TimeValue?  
.setQuery( qb )  
.setFrom(0) //?  
.setSize(5000); //number of jsons to get in each search, what should it be?  
I have no idea.  
SearchResponse scrollResp = searchBuilder.execute().actionGet();

Is it expected that scanning and scrolling just takes a long time when  
examining many results? I'm very new to Elastic Search so keep in mind that  
I may be missing something very obvious.

Note: also posted at

> <https://stackoverflow.com/questions/13464821/how-do-i-reduce-elasticsearch-scroll-response-time>

--

---

<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 6, 2017, 3:03am UTC](https://discuss.elastic.co/t/how-do-i-reduce-scroll-response-time/9766/2 "2017-07-06T03:03:38Z")

</div>


