Specifying a Retention Policy

The keep policy determines the basis for retaining rows in a window.

You can set a keep policy, also called a retention policy, for any window with a memory-based store, including any simple query that produces a window.

Retention policies for windows that use a log store are only supported for input windows.

Keep Policy Options
Options Description
All rows Retain all rows in the window (default).
Last row Retain only the last row in the window.
Count Either:
  • Enter the absolute number of rows to retain, or,
  • Choose Select and select a previously declared variable or parameter to determine a specific range of rows to retain in the window.
    Tip: If the list is empty and you want to base the count on a parameter or variable, switch to the CCL editor and define it in a DECLARE block at the beginning of the CCL. For example:
    DECLARE 
    integer test :=50;
    end;
    Then go back and select it.
Every

(Optional) Works with the Count and Time options.

When used with the Count option, Every retains a number of rows based on the Count value specified, and purges all of the retained rows once a row arrives that would exceed the specified maximum number of rows. This purge will only occur once the specified Count number has been reached.

When used with the Time option, Every retains a number of rows within a specified time interval. Once the time interval expires, all rows are purged simultaneously.

Note: When this option is used, the resulting retention is based on a Jumping Window policy. Otherwise, the resulting retention is based on a Sliding Window policy.
Slack For a count-based policy, set the number of rows to delete when the maximum number of rows is reached (the Count value). Default is 1, that is, when the window contains count_value rows, each new row causes the oldest row to be deleted. Setting slack to greater than 1 can optimize performance.
Time Set a time limit on the window, and specify a time period to determine what age of row to retain in the window. Press Ctrl+Space to choose the unit of time.
PER clause

(Optional) Works with the Time and Count options.

When used with the Count option, PER works in conjunction with the specified Count number to retain the Count number of rows across each column specified under the PER clause.

When used with the Time option, PER works in conjunction with the specified Time interval to retain the rows within that Time interval across each column specified under the PER clause.

List the names of the columns that need to be retained in the PER clause box, with a comma separating each column name entered.

Count

In a Sliding Window count-based retention policy, a constant integer specifies the maximum number of rows retained in the window. To retain the specified maximum number of rows in the window, the policy purges the oldest entries as new entries arrive, one row at a time.

In a Jumping Window count-based retention policy, enabled by using the Every option, all rows are purged only once a row arrives that would exceed the specified maximum number of rows.

A Sliding Window count-based policy also defines an optional Slack value, which can enhance performance by requiring less frequent cleaning of memory stores.

Slack

Slack is an advanced feature used to enhance performance by requiring less frequent cleaning of memory stores. It sets a maximum of N + S rows in the window, where N is the retention size (the count setting) and S is the slack. When the window reaches N + S rows the systems purges S rows. The larger the value of slack the better the performance is, since there is less cleaning required.

The default value for slack is 1. When slack = 1, after the window reaches the maximum number of records, each time a new record is inserted, the oldest record is deleted. This causes a significant impact on performance. When slack > 1, say Y, then the window will accumulate up to X + Y number of records. The next record inserted will then cause the deletion of Y records. Larger slack values improve performance by reducing the need to constantly delete rows.

Note: The SLACK value cannot be used with the 'Every' option, and thus cannot be used in a Jumping Window count-based retention policy.

Time

In a Sliding Window time-based retention policy, a time interval specifies the maximum age of the rows retained in the window. Rows are purged from the window, one row at a time, when they becomes older than the specified interval.

In a Jumping Window time-based retention policy, enabled by using the Every option, all rows produced in the specified time interval are purged after the interval has expired.

PER Clause

The PER Clause allows for rows specified by the Count or Time options to be retained across specified columns.

For a count-based retention policy, it keeps the number of rows specified by the Count number across each column specified under the PER Clause. The rows in each column specified to be retained will update simultaneously to delete older entries as newer ones arrive.

For a time-based retention policy, it keeps rows within the specified Time interval across each column specified under the PER Clause. The rows in each column specified to be retained will update simultaneously to delete older entries as the time interval expires.