# Activity Retry Temporal Database consumption

**URL:** <https://community.temporal.io/t/activity-retry-temporal-database-consumption/13166>\
**Category:** Community Support\
**Tags:** database\
**Created:** [August 14, 2024, 12:06pm UTC](https://community.temporal.io/t/activity-retry-temporal-database-consumption/13166 "2024-08-14T12:06:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelKruglov](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@MichaelKruglov](https://community.temporal.io/u/MichaelKruglov)\
**Post date:** [August 14, 2024, 12:06pm UTC](https://community.temporal.io/t/activity-retry-temporal-database-consumption/13166/1 "2024-08-14T12:06:32Z")

</div>

In our project we use workflows with multiple activity retries and long WF timeout (syncronisaion process with another services).

So I want to understand how my Temporal Database memory will be consumed.  
Is a new table raw related to ActivityTask created every time this Activity is processed? So if I retry Activity 1000 times will 1000 records be created which consumes large amount of memory?  
Or does it use existing information about Activity and does not create new record for every attempt?

I am working on two approaches with retries:  
**First Approach** : Temporal Activity Retries  
Temporal will try to retry activity when code throws an exception.  
So we can see _Activity Pending_ in UI

**Second Approach** : Manual activity retries like here:

```auto
synced = false
while(!synced) {
   try{
    activity.start()
    synced = true
  } catch (exception) {
     //log and continue retries
  }
}

```

So in UI History we can see new ActivityTask for every manual retry.

I am wondering what approach will be better to avoid multiple records creation and save memory in my Temporal DB cluster.  
Or maybe there is some sort of clearing mechanism that will delete old acitivityTask records

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 14, 2024, 5:12pm UTC](https://community.temporal.io/t/activity-retry-temporal-database-consumption/13166/2 "2024-08-14T17:12:57Z")

</div>

Use Temporal activity retries. They don’t create new records on each retry.

---

<div class="post-metadata">

**Author:** ![MichaelKruglov](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@MichaelKruglov](https://community.temporal.io/u/MichaelKruglov)\
**Post date:** [August 15, 2024, 9:58am UTC](https://community.temporal.io/t/activity-retry-temporal-database-consumption/13166/3 "2024-08-15T09:58:08Z")

</div>

@maxim Thank you for your answer!

But what about 2nd approach? Will it consume DB space for multiple activity records?  
And does Temporal have DB clearing mechanism?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 15, 2024, 5:36pm UTC](https://community.temporal.io/t/activity-retry-temporal-database-consumption/13166/4 "2024-08-15T17:36:22Z")

</div>

The second approach grows the workflow history for each retry. Thus, the workflow must call continue-as-new to keep the history size bounded. Once the workflow continues as new, the retention timer starts. After the retention period, the workflow history will be deleted.
