# Delete By Query in ES 5.0.1 Slower than Expected

**URL:** https://discuss.elastic.co/t/delete-by-query-in-es-5-0-1-slower-than-expected/74554
**Category:** Elasticsearch
**Created:** [February 9, 2017, 7:45pm UTC](https://discuss.elastic.co/t/delete-by-query-in-es-5-0-1-slower-than-expected/74554 "2017-02-09T19:45:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ben-10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben-10/32/12306_2.png) [@ben-10](https://discuss.elastic.co/u/ben-10)
#### Post date: [February 9, 2017, 7:45pm UTC](https://discuss.elastic.co/t/delete-by-query-in-es-5-0-1-slower-than-expected/74554/1 "2017-02-09T19:45:33Z")

</div>

First time testing out this function and not quite sure what to expect in terms of performance. Can anyone comment if this seems right or can be further optimized to perform better?

Single index: logstash\_asa\_2016.12.31  
Total documents: 179,345,189  
Documents tagged with "vpn": 5,303,648

delete\_by\_query command issues at around 10:45 or 11:19 CST, _command is still running_ as of 13:41 CST

search rate on the index is between 20-40 docs/second

```
curl -XPOST 'localhost:9200/logstash_asa_2016.12.31/_delete_by_query?pretty=true' -d '
 {
     "query" : {
         "bool" : {
             "must_not" :{
                 "term" : { "tags": "vpn" }
             }
         }
     }
 }'
```

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [February 9, 2017, 9:30pm UTC](https://discuss.elastic.co/t/delete-by-query-in-es-5-0-1-slower-than-expected/74554/2 "2017-02-09T21:30:40Z")

</div>

It is worth looking at the `_tasks` API to see if you can find the task. That should tell you at least something about what it is up to.

In general it tends to be faster to build a new index rather than delete 97% of an index.

---

<div class="post-metadata">

### Author: ![ben-10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben-10/32/12306_2.png) [@ben-10](https://discuss.elastic.co/u/ben-10)
#### Post date: [February 9, 2017, 10:23pm UTC](https://discuss.elastic.co/t/delete-by-query-in-es-5-0-1-slower-than-expected/74554/3 "2017-02-09T22:23:02Z")

</div>

Thanks for the feedback and direction. I agree with the amount of tagged data being so skewed, it would be much quicker to split into a separate index. Also makes it easier to schedule Curator to erase that other index pattern to attempt to reclaim disk space.

---

<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: [March 9, 2017, 10:23pm UTC](https://discuss.elastic.co/t/delete-by-query-in-es-5-0-1-slower-than-expected/74554/4 "2017-03-09T22:23:36Z")

</div>

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