Activity Retry Temporal Database consumption

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:

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

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

@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?

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.