# Expiring an entire set using a lua script

**URL:** https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512
**Category:** Deletion
**Created:** [September 13, 2023, 9:43pm UTC](https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512 "2023-09-13T21:43:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![srikumarkpz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/srikumarkpz/32/2141_2.png) [@srikumarkpz](https://discuss.aerospike.com/u/srikumarkpz)
#### Post date: [September 13, 2023, 9:43pm UTC](https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512/1 "2023-09-13T21:43:40Z")

</div>

Hi,

Came across this solution in stackoverflow where you can delete entire contents of a set by updating the TTL: [Changing TTL for a set in Aerospike with AQL - Stack Overflow](https://stackoverflow.com/questions/73747443/changing-ttl-for-a-set-in-aerospike-with-aql)

Would like to apply this solution in our production environment where we have records in the range of billions . Above solution creates a scan job in the background.

What would be the performance impact on a cluster with 20 nodes and the set having 4,843,572,506 records ? (Memory, cpu usage, latency etc)

Thanks in advance Sri

---

<div class="post-metadata">

### Author: ![meher](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/meher/32/1644_2.png) [@meher](https://discuss.aerospike.com/u/meher)
#### Post date: [September 14, 2023, 8:00pm UTC](https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512/2 "2023-09-14T20:00:55Z")

</div>

Why not use the [truncate info command](https://docs.aerospike.com/reference/info#truncate)?

In the Enterprise Edition version, this will be durable. If using the Community Edition, records may still resurrect upon restart if deleting records by setting a TTL when they previously had no TTL or were going to expire at a later time. I am therefore curious about the use case for wanting to delete the content of a set by setting a TTL.

---

<div class="post-metadata">

### Author: ![srikumarkpz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/srikumarkpz/32/2141_2.png) [@srikumarkpz](https://discuss.aerospike.com/u/srikumarkpz)
#### Post date: [September 14, 2023, 8:20pm UTC](https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512/3 "2023-09-14T20:20:24Z")

</div>

Meher,

Truncate seems like a better option - use case is to shrink the data for a set (which has grown over time) and is consuming quite a bit of memory and diskspace. Once the set is cleared, want to re populate the data using a smaller subset of the original set

Sri

---

<div class="post-metadata">

### Author: ![meher](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/meher/32/1644_2.png) [@meher](https://discuss.aerospike.com/u/meher)
#### Post date: [September 14, 2023, 8:47pm UTC](https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512/4 "2023-09-14T20:47:12Z")

</div>

Then truncate would definitely be the way to go. You can check the docs, with the config (`truncate-threads`) and the optional LUT that can be passed.

---

<div class="post-metadata">

### Author: ![srikumarkpz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/srikumarkpz/32/2141_2.png) [@srikumarkpz](https://discuss.aerospike.com/u/srikumarkpz)
#### Post date: [September 14, 2023, 9:02pm UTC](https://discuss.aerospike.com/t/expiring-an-entire-set-using-a-lua-script/10512/5 "2023-09-14T21:02:51Z")

</div>

Thanks Meher. Appreciate the quick responses.

Sri
