# When deleting by query api the number of deleted\_docs and index size\_in\_bytes does not decrease

**URL:** <https://discuss.elastic.co/t/when-deleting-by-query-api-the-number-of-deleted-docs-and-index-size-in-bytes-does-not-decrease/16212>\
**Category:** Elasticsearch\
**Created:** [March 6, 2014, 11:09pm UTC](https://discuss.elastic.co/t/when-deleting-by-query-api-the-number-of-deleted-docs-and-index-size-in-bytes-does-not-decrease/16212 "2014-03-06T23:09:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_Damiano](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@Rob\_Damiano](https://discuss.elastic.co/u/Rob_Damiano)\
**Post date:** [March 6, 2014, 11:09pm UTC](https://discuss.elastic.co/t/when-deleting-by-query-api-the-number-of-deleted-docs-and-index-size-in-bytes-does-not-decrease/16212/1 "2014-03-06T23:09:19Z")

</div>

Hi,

I've performed a delete by query and the number of deleted\_docs and index  
size\_in\_bytes does not decrease. I've also looked through the ES mailing  
group and tried the recommended optimize, but I'm still not seeing expected  
results. Here is my test case:

_curl [http://localhost:9200/apacheal/\_stats/](http://localhost:9200/apacheal/_stats/)  
 [http://localhost:9200/apacheal/\_stats/](http://localhost:9200/apacheal/_stats/)_

{"ok":true,"\_shards":{"total":10,"successful":5,"failed":0},"\_all":{"primaries":{"docs":{"count":  
_106407607_,"deleted":_809677_},"store":{"size":"45.5gb","size\_in\_bytes":  
_48894062436_  
,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246172},"indexing":{"index\_total":56322858,"index\_time":"8.4h","index\_time\_in\_millis":30412645,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}},"total":{"docs":{"count":106407607,"deleted":809677},"store":{"size":"45.5gb","size\_in\_bytes":48894062436,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246172},"indexing":{"index\_total":56322858,"index\_time":"8.4h","index\_time\_in\_millis":30412645,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}}},"indices":{"apacheal":{"primaries":{"docs":{"count":106407607,"deleted":809677},"store":{"size":"45.5gb","size\_in\_bytes":48894062436,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246172},"indexing":{"index\_total":56322858,"index\_time":"8.4h","index\_time\_in\_millis":30412645,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}},"total":{"docs":{"count":106407607,"deleted":809677},"store":{"size":"45.5gb","size\_in\_bytes":48894062436,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246172},"indexing":{"index\_total":56322858,"index\_time":"8.4h","index\_time\_in\_millis":30412645,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}}}}}

_curl -XDELETE [http://localhost:9200/apacheal/events/\_query](http://localhost:9200/apacheal/events/_query)  
 [http://localhost:9200/apacheal/events/\_query](http://localhost:9200/apacheal/events/_query) -d "{  
"range":{"timestamp":{"lte":"2014-02-12T23:59:59-05:00"}} }"_

{"ok":true,"\_indices":{"apacheal":{"\_shards":{"total":5,"successful":5,"failed":0}}}}

_curl http:// [http://logs.flyptech.com:9200/apacheal/\_stats/](http://logs.flyptech.com:9200/apacheal/_stats/)localhost  
 [http://localhost:9200/apacheal/\_stats/](http://localhost:9200/apacheal/_stats/):9200/apacheal/\_stats/_

{"ok":true,"\_shards":{"total":10,"successful":5,"failed":0},"\_all":{"primaries":{"docs":{"count":  
_100703300_,"deleted":_4961760_},"store":{"size":"45.5gb","size\_in\_bytes":  
_48896498586_  
,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246326},"indexing":{"index\_total":56324061,"index\_time":"8.4h","index\_time\_in\_millis":30413483,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}},"total":{"docs":{"count":100703300,"deleted":4961760},"store":{"size":"45.5gb","size\_in\_bytes":48896498586,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246326},"indexing":{"index\_total":56324061,"index\_time":"8.4h","index\_time\_in\_millis":30413483,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}}},"indices":{"apacheal":{"primaries":{"docs":{"count":100703300,"deleted":4961760},"store":{"size":"45.5gb","size\_in\_bytes":48896498586,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246326},"indexing":{"index\_total":56324061,"index\_time":"8.4h","index\_time\_in\_millis":30413483,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}},"total":{"docs":{"count":100703300,"deleted":4961760},"store":{"size":"45.5gb","size\_in\_bytes":48896498586,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246326},"indexing":{"index\_total":56324061,"index\_time":"8.4h","index\_time\_in\_millis":30413483,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}}}}}

_RAN OPTIMIZE THROUGH UI_

_curl http:// [http://logs.flyptech.com:9200/apacheal/\_stats/](http://logs.flyptech.com:9200/apacheal/_stats/)**localhost  
 [http://localhost:9200/apacheal/\_stats/](http://localhost:9200/apacheal/_stats/)**:9200/apacheal/\_stats/  
 [http://logs.flyptech.com:9200/apacheal/\_stats/](http://logs.flyptech.com:9200/apacheal/_stats/)_

{"ok":true,"\_shards":{"total":10,"successful":5,"failed":0},"\_all":{"primaries":{"docs":{"count":  
_100705106_,"deleted":_4961760_},"store":{"size":"44.8gb","size\_in\_bytes":  
_48159890359_  
,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246687},"indexing":{"index\_total":56325867,"index\_time":"8.4h","index\_time\_in\_millis":30417576,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}},"total":{"docs":{"count":100705106,"deleted":4961760},"store":{"size":"44.8gb","size\_in\_bytes":48159890359,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246687},"indexing":{"index\_total":56325867,"index\_time":"8.4h","index\_time\_in\_millis":30417576,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}}},"indices":{"apacheal":{"primaries":{"docs":{"count":100705106,"deleted":4961760},"store":{"size":"44.8gb","size\_in\_bytes":48159890359,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246687},"indexing":{"index\_total":56325867,"index\_time":"8.4h","index\_time\_in\_millis":30417576,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}},"total":{"docs":{"count":100705106,"deleted":4961760},"store":{"size":"44.8gb","size\_in\_bytes":48159890359,"throttle\_time":"7.8h","throttle\_time\_in\_millis":28246687},"indexing":{"index\_total":56325867,"index\_time":"8.4h","index\_time\_in\_millis":30417576,"index\_current":0,"delete\_total":0,"delete\_time":"0s","delete\_time\_in\_millis":0,"delete\_current":0},"get":{"total":0,"get\_time":"0s","time\_in\_millis":0,"exists\_total":0,"exists\_time":"0s","exists\_time\_in\_millis":0,"missing\_total":0,"missing\_time":"0s","missing\_time\_in\_millis":0,"current":0},"  
search  
":{"open\_contexts":0,"query\_total":2020,"query\_time":"2.5h","query\_time\_in\_millis":9351789,"query\_current":0,"fetch\_total":1536,"fetch\_time":"4.4m","fetch\_time\_in\_millis":267579,"fetch\_current":0}}}}}

When I deleted, the document count went down by ~5.7 million records, which  
was expected, but the deleted only increase by ~ 4.2 million, which is not  
exactly expected. The size\_in\_bytes only decrease by ~ 2.4 MB, and then  
after the optimize only decrease by ~ 700 MB. This is not what I was  
expecting at all. Each of the records is about 500 bytes, so 500 bytes \*  
5.7 million records = 2.65 GB. Why is the deleted documents and size in  
bytes not decreasing significantly?

Thanks for your help,

Rob

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1bc61dd1-26ff-4e0a-89a7-c5f2ba95cc10%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1bc61dd1-26ff-4e0a-89a7-c5f2ba95cc10%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 6, 2014, 11:13pm UTC](https://discuss.elastic.co/t/when-deleting-by-query-api-the-number-of-deleted-docs-and-index-size-in-bytes-does-not-decrease/16212/2 "2014-03-06T23:13:22Z")

</div>

Curious, when you ran optimize, what did you pass to the max\_num\_segments  
parameter?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1c8980ca-7305-4a2e-a1b5-40cc104d3616%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1c8980ca-7305-4a2e-a1b5-40cc104d3616%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Rob\_Damiano](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@Rob\_Damiano](https://discuss.elastic.co/u/Rob_Damiano)\
**Post date:** [March 6, 2014, 11:23pm UTC](https://discuss.elastic.co/t/when-deleting-by-query-api-the-number-of-deleted-docs-and-index-size-in-bytes-does-not-decrease/16212/3 "2014-03-06T23:23:21Z")

</div>

I passed 1.

Rob

On Thu, Mar 6, 2014 at 6:13 PM, Binh Ly [binhly\_es@yahoo.com](mailto:binhly_es@yahoo.com) wrote:

> Curious, when you ran optimize, what did you pass to the max\_num\_segments  
> parameter?
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/-3zp0biP4dQ/unsubscribe](https://groups.google.com/d/topic/elasticsearch/-3zp0biP4dQ/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1c8980ca-7305-4a2e-a1b5-40cc104d3616%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1c8980ca-7305-4a2e-a1b5-40cc104d3616%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/1c8980ca-7305-4a2e-a1b5-40cc104d3616%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/1c8980ca-7305-4a2e-a1b5-40cc104d3616%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--

\*ROBERT DAMIANO \*

_Senior Developer_

_T:_ 888 694 2946

\*E: \*rob.damiano@uberflip.com

_W:_ [uberflip.com](http://uberflip.com)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CA%2BUUMJjbcSwd\_%2Bnwee3qB3U4ZOj8DLJ5U\_N61x9S0dbP9K1XfQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CA%2BUUMJjbcSwd_%2Bnwee3qB3U4ZOj8DLJ5U_N61x9S0dbP9K1XfQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:45am UTC](https://discuss.elastic.co/t/when-deleting-by-query-api-the-number-of-deleted-docs-and-index-size-in-bytes-does-not-decrease/16212/4 "2017-07-06T01:45:11Z")

</div>


