ALTER MATERIALIZED VIEW SET TTL
Sets the time-to-live (TTL) period on a materialized view.
Syntax
Description
To keep only recent aggregated data in a materialized view, configure a
time-to-live (TTL) period on the view using the
ALTER MATERIALIZED VIEW SET TTL
command.
The value follows the same rules as the one in the
ALTER TABLE SET TTL
command.
note
QuestDB drops data that exceeded its TTL only a whole partition at a time. For this reason, the TTL period must be a whole number multiple of the view's partition size.
Examples
Set the TTL to 3 days:
ALTER MATERIALIZED VIEW trades_hourly_prices SET TTL 3 DAYS;
Set the TTL to 12 hours, using the shorthand syntax for the time unit:
ALTER MATERIALIZED VIEW trades_hourly_prices SET TTL 12h;