All Products
Search
Document Center

Lindorm:CREATE PREDOWNSAMPLE

Last Updated:Mar 28, 2026

Creates pre-downsampling rules that control how LindormTSDB aggregates time series data at a reduced resolution for storage and query efficiency.

Applicable engines and versions

Applies to LindormTSDB only. All versions are supported.

Syntax

create_predownsample_statement ::= CREATE PREDOWNSAMPLE time_interval
                                    AGGREGATORS ('function_identifier' [, 'function_identifier'] ...)
                                    [ TTL time_interval ] ON table_identifier
time_interval                  ::= interval units

Parameters

ParameterDescription
intervalThe interval at which time series data is aggregated. Must be a positive integer.
unitsThe unit of the interval. Valid values: s (seconds), m (minutes), h (hours), d (days).
AGGREGATORSThe aggregation functions to apply during pre-downsampling. Valid values: count, first, last, min, max, sum.
function_identifierThe name of the aggregation function. A single statement can specify multiple functions with the same interval. Alternatively, define functions with the same interval across multiple statements.
TTLThe time to live (TTL) of the pre-downsampled data.
table_identifierThe name of the table for which pre-downsampling rules are configured.
The avg function is not supported. To calculate an average over pre-downsampled data, divide the sum result by the count result. If data is repeatedly added and overwritten, the computed average may be inaccurate.
If multiple pre-downsampling rules specify different TTL values, the largest TTL applies to all rules.

Query pre-downsampled data

By default, querying a table returns the original data, not the pre-downsampled data. To query only pre-downsampled data, add the /*+ PREDOWNSAMPLE */ hint to your query statement.

For more information, see Pre-downsampling.

Examples

Example 1: Create a pre-downsampling rule with a 90-day TTL

The following statement aggregates data in the sensor table hourly using sum and max, and retains the pre-downsampled data for 90 days.

CREATE PREDOWNSAMPLE `1h` AGGREGATORS (`sum`, `max`) TTL `90d` ON sensor;

Example 2: Query pre-downsampled data

The following statement queries hourly pre-downsampled data from the sensor table within a specified time range.

SELECT /*+ PREDOWNSAMPLE */ SUM(temperature) FROM sensor
WHERE time >= 1619076780000 AND time <= 1619076800000
SAMPLE BY 1h;