milvus-logo

Modify a collection

This topic describes how to modify the properties, especially the time to live (TTL), of a collection.

Currently, the TTL feature is only available in Python.

collection = Collection("books")
collection.set_properties(properties={"collection.ttl.seconds": 1800})
AlterCollectionParam alterCollectionParam = AlterCollectionParam.newBuilder
  .withCollectionName("books")
  .withTTL(1800)
client.AlterCollection(context.Background(), "books", entity.CollectionTTL(1800))

The example above changes the collection TTL to 1800 seconds.

Parameter Description Option
Properties: collection.ttl.seconds Collection time to live (TTL) is the expiration time of data in a collection. Expired data in the collection will be cleaned up and will not be involved in searches or queries. Specify TTL in the unit of seconds. The value should be 0 or greater. The default value is 0, which means TTL is disabled.

TTL only happens after compaction which means the expired data will be invisible and GC after segment compacted.

What's next

On this page