Keep 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.
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.

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.

Related tasks
Creating and Modifying Simple Queries: Aggregate
Creating and Modifying Simple Queries: Join