TSContainerPoolRoundRobin function

The TSContainerPoolRoundRobin function provides a round-robin policy for inserting time series data into containers in the specified container pool.

Syntax

TSContainerPoolRoundRobin(
      table_name lvarchar,
      column_name lvarchar,
      subtype lvarchar,
      irregular integer,
      pool_name lvarchar)
returns lvarchar;
table_name
The table into which the time series data is being inserted.
column_name
The name of the time series column into which data is being inserted.
subtype
The name of the TimeSeries subtype.
irregular
Whether the time series is regular (0) or irregular (1).
pool_name
The name of the container pool.

Description

Use the TSContainerPoolRoundRobin function to select containers in which to insert time series data from the specified container pool. The container pool must exist before you can insert data into it, and at least one container within the container pool must be configured for the same TimeSeries subtype as used by the data being inserted. Set the TSContainerPoolRoundRobin function to a container pool name and use it as the value for the container argument in the VALUES clause of an INSERT statement. The TSContainerPoolRoundRobin function returns container names to the INSERT statements in round-robin order.

Returns

The container name in which to store the time series value.

Example

The following statement inserts data into a time series. The TSContainerPoolRoundRobin function specifies that the container pool named readings is used in the container argument.

INSERT INTO smartmeters(meter_id,rawreadings)
     VALUES('met00001','origin(2006-01-01 00:00:00.00000),
            calendar(smartmeter),regular,threshold(0),
            container(TSContainerPoolRoundRobin(readings)),
                [(33070,-13.00,100.00,9.98e+34),
                 (19347,-4.00,100.00,1.007e+35),
                 (17782,-18.00,100.00,9.83e+34)]');

When the INSERT statement runs, the TSContainerPoolRoundRobin function runs with the following values:

TSContainerPoolRoundRobin('smartmeters','rawreadings', 
                          'smartmeter_row',0,'readings')

The TSContainerPoolRoundRobin function sorts the container names alphabetically and returns the first container name to the INSERT statement. The next time an INSERT statement is run, the TSContainerPoolRoundRobin function returns the second container name, and so on.