# TTL indexed secondary

**URL:** <https://forum.yugabyte.com/t/ttl-indexed-secondary/1220>\
**Category:** Design Discussions\
**Created:** [September 28, 2021, 8:37am UTC](https://forum.yugabyte.com/t/ttl-indexed-secondary/1220 "2021-09-28T08:37:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaidmd](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zaidmd](https://forum.yugabyte.com/u/zaidmd)\
**Post date:** [September 28, 2021, 8:37am UTC](https://forum.yugabyte.com/t/ttl-indexed-secondary/1220/1 "2021-09-28T08:37:53Z")

</div>

I need to expire data using a TTL with a table that uses a secondary index. How to remove data that currently expires using a TTL, but is unable to do due to the need for a secondary index?

Help anyone  
Thanks  
[Zaid explore](https://zaidexplore.blogspot.com/)

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [September 28, 2021, 11:02am UTC](https://forum.yugabyte.com/t/ttl-indexed-secondary/1220/2 "2021-09-28T11:02:22Z")

</div>

Hi @zaidmd

The problem is that indexes won’t be consistent. See issue on github: [[YCQL] Disallow inserts on tables with default\_ttl + secondary index. · Issue #6325 · yugabyte/yugabyte-db · GitHub](https://github.com/yugabyte/yugabyte-db/issues/6325)

Maybe you can keep an “expire\_at” column and periodically delete rows ?

---

<div class="post-metadata">

**Author:** ![karthik](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/karthik/32/13_2.png) [@karthik](https://forum.yugabyte.com/u/karthik)\
**Post date:** [September 28, 2021, 5:01pm UTC](https://forum.yugabyte.com/t/ttl-indexed-secondary/1220/3 "2021-09-28T17:01:23Z")

</div>

Hi @zaidmd,

I am assuming you are using YCQL, since only that API supports TTL.

Are you ok with using `user_enforced` consistency level? See details here: [Document details of user enforced consistency · Issue #1696 · yugabyte/yugabyte-db · GitHub](https://github.com/yugabyte/yugabyte-db/issues/1696)

If so, you can set a TTL on the primary table and the different indexes - and they would all get TTL’ed separately. Does that work for you?
