# Alternative for Delete By Query or Solution for Performance improvement

**URL:** <https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298>\
**Category:** Elasticsearch\
**Created:** [May 6, 2021, 1:04pm UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298 "2021-05-06T13:04:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrunalini](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mrunalini](https://discuss.elastic.co/u/mrunalini)\
**Post date:** [May 6, 2021, 1:04pm UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/1 "2021-05-06T13:04:39Z")

</div>

Hi ,

We have index in ELK ,where we are storing transaction details ,where we want to delete some records after some time.

As quantity of requests is so high ,its taking so much time to complete the execution of the Delete query(almost 4-5 hours) .

So is there alternative to delete this data without any performance issue or any alternative to Delete by Query which will make deletion faster.

Please suggest.

Thanks ,  
Mrunalini

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 6, 2021, 1:12pm UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/2 "2021-05-06T13:12:09Z")

</div>

Deleting docs is expensive but deleting whole indices is quick/cheap.  
This is why we advocate using "time-based indices" e.g. keeping one per month and then moving old indices to backup storage or dropping whole indices after a time. This practice has been formalised in the idea of [datastreams](https://www.elastic.co/guide/en/elasticsearch/reference/current/set-up-a-data-stream.html)

---

<div class="post-metadata">

**Author:** ![mrunalini](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mrunalini](https://discuss.elastic.co/u/mrunalini)\
**Post date:** [May 6, 2021, 2:19pm UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/3 "2021-05-06T14:19:23Z")

</div>

We already have monthly indexes , but we cant afford to loose whole data ,so is there any possible way we can increase Delete Query performance .

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 6, 2021, 2:29pm UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/4 "2021-05-06T14:29:10Z")

</div>

Use weekly indices?  
Or are you saying not all documents in a time-based index expire at the same time?

---

<div class="post-metadata">

**Author:** ![mrunalini](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mrunalini](https://discuss.elastic.co/u/mrunalini)\
**Post date:** [May 7, 2021, 6:35am UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/5 "2021-05-07T06:35:16Z")

</div>

Hi Mark,

Thank you for instant reply !!

We have Index where we are logging documents with request and response payload for few number of transaction ,not for all the transaction.

So what we are thinking is we can delete the just request -response payload of that particular transaction after 15 days may be, so that storage issue will not be there.

So we have problem for using DBQ for this as it take so much time.  
Please suggest.

Thanks and regards,  
Mrunalini

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 7, 2021, 7:06am UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/6 "2021-05-07T07:06:29Z")

</div>

Keep 15 indexes each with a day’s worth of content. Each day create a new one and delete the oldest - this is a typical time-based indexing policy.

---

<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:** [June 4, 2021, 7:07am UTC](https://discuss.elastic.co/t/alternative-for-delete-by-query-or-solution-for-performance-improvement/272298/7 "2021-06-04T07:07:28Z")

</div>

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