# Slow query

**URL:** <https://discuss.elastic.co/t/slow-query/7756>\
**Category:** Elasticsearch\
**Created:** [May 18, 2012, 6:22am UTC](https://discuss.elastic.co/t/slow-query/7756 "2012-05-18T06:22:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [May 18, 2012, 6:22am UTC](https://discuss.elastic.co/t/slow-query/7756/1 "2012-05-18T06:22:39Z")

</div>

why wildcard query is taking too much time to get large number of documents  
I have a query

{ "query": {  
"bool": {  
"must": [  
{  
"wildcard": {  
"Item.HinTitleLink": "_songs.pk_"  
}  
}  
]  
}  
},  
"from": 0,  
"size": 1000  
}  
result

{

- took: 2812
- timed\_out: false
- \_shards: {
  - total: 5
  - successful: 5
  - failed: 0  
}

when I increase size to 10000 it does not execute at all.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 18, 2012, 7:48am UTC](https://discuss.elastic.co/t/slow-query/7756/2 "2012-05-18T07:48:13Z")

</div>

Sending back 10000 docs to a user is just scary.  
I can't read 1000 results.

Seems that you want to extract documents for your use case.  
Have a look at the scan & scroll features.

HTH  
David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 18 mai 2012 à 08:22, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a écrit :

> why wildcard query is taking too much time to get large number of documents  
> I have a query
> 
> { "query": {  
> "bool": {  
> "must": [  
> {  
> "wildcard": {  
> "Item.HinTitleLink": "_songs.pk_"  
> }  
> }  
> ]  
> }  
> },  
> "from": 0,  
> "size": 1000  
> }  
> result
> 
> {  
> took: 2812  
> timed\_out: false  
> \_shards: {  
> total: 5  
> successful: 5  
> failed: 0  
> }  
> when I increase size to 10000 it does not execute at all.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 20, 2012, 8:20pm UTC](https://discuss.elastic.co/t/slow-query/7756/3 "2012-05-20T20:20:25Z")

</div>

wildcard queries are slow, especially one with leading wildcards. Try and  
use ngram based analysis to "simulate" wildcard.

On Fri, May 18, 2012 at 8:22 AM, jajoria abhishek \<  
[jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com)\> wrote:

> why wildcard query is taking too much time to get large number of  
> documents  
> I have a query
> 
> { "query": {  
> "bool": {  
> "must": [  
> {  
> "wildcard": {  
> "Item.HinTitleLink": "_songs.pk_"  
> }  
> }  
> ]  
> }  
> },  
> "from": 0,  
> "size": 1000  
> }  
> result
> 
> {
> 
> - took: 2812
> - timed\_out: false
> - \_shards: {
> - total: 5
> - successful: 5
> - failed: 0  
> }
> 
> when I increase size to 10000 it does not execute at all.

---

<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:27am UTC](https://discuss.elastic.co/t/slow-query/7756/4 "2017-07-06T03:27:59Z")

</div>


