Version:

TTL

Time-to-live (TTL) is the configured number of minutes since last access before a table or view will expire. A TTL of -1 will direct that an entity not expire.

When a collection is assigned a TTL, all tables & views that are not protected within the collection will take on that TTL; those that are protected will be skipped. The assignment for the collection itself, however, is transient, as a collection does not have a TTL of its own. As a result, any tables or views added to the collection after setting its TTL will not take on that TTL. Lacking a TTL, a collection will not expire.

Each time a table or view is accessed, its expiration timer will be reset to the value of its configured TTL. For instance, a view with a five minute TTL will have its life extended by five minutes from the time it is accessed every time it is accessed. If it is not accessed within five minutes from the time of last access, it will be removed.

Tables, by default, will not expire. Views, by default, will expire in the number of minutes configured within the server's default_ttl setting.

A TTL can be any of the following:

  • n - the database entity will live for n minutes since last access, where n is a positive integer
  • 0 - the database entity will expire immediately
  • -1 - the database entity will not expire

Note

TTL only governs an entity's expiration by timeout. For example, a memory-only table with a TTL set to not expire will still be removed from the system upon database restart.

Example

To assign a 5-minute TTL to a table, in Python:

gpudb.alter_table(
  table_name = "nyctaxi",
  action = "ttl",
  value = "5"
)

To set a table to not expire, in Python:

gpudb.alter_table(
  table_name = "nyctaxi",
  action = "ttl",
  value = "-1"
)