# Deleting data up to a specific version

**URL:** <https://forums.foundationdb.org/t/deleting-data-up-to-a-specific-version/3875>\
**Category:** Using FoundationDB\
**Created:** [March 28, 2023, 3:27pm UTC](https://forums.foundationdb.org/t/deleting-data-up-to-a-specific-version/3875 "2023-03-28T15:27:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbs](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/hbs/32/1419_2.png) [@hbs](https://forums.foundationdb.org/u/hbs)\
**Post date:** [March 28, 2023, 3:27pm UTC](https://forums.foundationdb.org/t/deleting-data-up-to-a-specific-version/3875/1 "2023-03-28T15:27:28Z")

</div>

Hi,

is there a way to instruct FDB to perform a clearrange but only up to a certain version, that is only delete an entry if it was committed with a version less than a cut off version?

If that is not possible, is there a way to “expire” data in the storage servers, pretty much like HBase would do it with its TTLs?

---

<div class="post-metadata">

**Author:** ![jzhou](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/jzhou/32/445_2.png) [@jzhou](https://forums.foundationdb.org/u/jzhou)\
**Post date:** [March 29, 2023, 5:57am UTC](https://forums.foundationdb.org/t/deleting-data-up-to-a-specific-version/3875/2 "2023-03-29T05:57:19Z")

</div>

If you can encode the version as part of the key for every keys, then the answer is yes. To do this, you may use the `VersionStamp` feature, which needs 10 bytes, as the key prefix. Then you can delete all keys whose commit versions are less than a version (converted to a versionstamp prefix).

A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-endian order). The last 2 bytes are monotonic in the serialization order for transactions (serialized in big-endian order).
