Row Count Delays With OUTPUT AFTER

Delay output rows by a specific number of rows. A description of how to enable row delay, and what syntax to use.

INSERT INTO StockTradesAll 
SELECT * 
FROM StockTrades 
OUTPUT AFTER 2 ROWS;

Here is an illustration of how row delay works:



In the above query, the first row in the input stream was published to the output stream when the third row in the input stream arrived and was sent to be published (delaying the first row by two rows). Note that after the row with tradeid 5008 is published (when tradeid 5010 arrives), no other output appears to be published. Since the example StockTrades data only has 11 events, the last two events won't be published until more rows arrive, permitting the OUTPUT AFTER 2 ROWS clause to be satisfied.

Note:

This does not happen with interval-based delays, because regardless of whether other rows arrive, time continues to be monitored and when Sybase CEP's internal clock reaches the point when the rows should be published, the rows will be published.

When a row count is used with OUTPUT AFTER, the row count delay is actually based on the number of rows being published to the output stream, not the rows arriving in the input stream. When there is no filter in the query, as in the above example, these events are equivalent (since all rows arriving in the input stream will be simultaneously ready for the output stream).

The introduction of a WHERE clause that filters output causes a change in the timing of output publication:



Note that when a WHERE clause is used, the first row that is published (the row with tradeid 5004) is delayed until the row with tradeid 5007 (not tradeid 5006) is processed. This is because the row with tradeid 5006 is not published at all (it doesn't meet the filter condition) and is not counted when delaying the output rows.


Created March 8, 2010. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com