TairTS is a time series data structure built as a Redis module. It provides low-latency, high-concurrency in-memory read and write access, supports fast filtering and aggregate queries, and handles both storage and computation of time series data.
Key concepts
TairTS organizes data in a three-level hierarchy:
Pkey: A named container for a set of related timelines (skeys). Each pkey can hold multiple skeys.
Skey: A single timeline within a pkey. An skey consists of multiple fixed-capacity chunks and can have one or more labels attached for filtering.
Chunk: A data storage unit within an skey. Each chunk stores multiple data points.
The default chunk capacity is 256. Without compression, a chunk stores up to 256 data points. With compression enabled, a chunk stores more than 256 data points, depending on the compression ratio.
Chunks are the smallest expiration unit. A chunk is deleted when all its data points expire.
Data point: A single time series measurement, consisting of a Unix timestamp (milliseconds) and a DOUBLE-type value.
The multi-level structure (pkey → skey → chunk → data point) lets you group related timelines and run aggregate queries across multiple skeys in a single command, without embedding aggregation logic in your application code.
In addition to multi-timeline aggregate queries, TairTS provides the following capabilities:
Update and accumulation of historical time series data.
Timeline-level TTL setting, which ensures that each timeline can automatically scroll according to a time window.
Efficient Gorilla compression algorithm with specific storage optimizations to significantly reduce costs.
Use cases
Storage and computing of monitored data
Per-second monitoring for application performance management (APM)
Data analytics and processing for IoT (Internet of Things)
Data analytics over time windows
Caching of hot news feeds
Risk control in throttling scenarios
Prerequisites
Before you begin, make sure you have:
A Tair DRAM-based instance
If the instance is compatible with Redis 5.0: minor version 1.7.20 or later
Update the instance to the latest minor version for the best feature support and stability. For cluster and read/write splitting instances, also update the proxy nodes to the latest minor version so that all commands run as expected. For more information, see Update the minor version of an instance.
Usage notes
TairTS data is stored on the Tair instance.
TairTS supports real-time, high-concurrency writes and queries but has limited storage capacity. Set a TTL for TairTS data to ensure expired data is deleted promptly.
Breaking change in version 24.7.0.0 On July 22, 2024, Tair DRAM-based instances compatible with Redis 6.0 were updated to version 24.7.0.0. This version introduces the ts-auto-del-empty-skey-enable parameter, which defaults to yes. When set to yes, an skey is automatically deleted when all its data points expire. In versions prior to 24.7.0.0, expired skeys are not deleted by default. Before using TairTS on a Redis 6.0-compatible instance, upgrade to version 24.7.0.0 or later and confirm and manually adjust the ts-auto-del-empty-skey-enable parameter settings to avoid unexpected behavior in your application.
Best practices
Set CHUNK_SIZE based on your data volume
To optimize memory usage and read/write performance, tune CHUNK_SIZE according to the average number of data points per skey:
| Average data points per skey | Recommended CHUNK_SIZE | Reason |
|---|---|---|
| More than 5,000 | 256 (default) | Larger chunks reduce chunk count and metadata overhead |
| Fewer than 5,000 | Average / 20 (e.g., 50 for 1,000 points) | Smaller chunks reduce decompression cost for small-range queries |
Setting a small CHUNK_SIZE with high write volumes causes many chunks to be created, which can degrade performance.Always set a TTL for skeys
TairTS has limited storage capacity. Specify DATA_ET when creating skeys or adding data points so that expired data is cleaned up automatically.
Command list
| Type | Command | Syntax | Description |
|---|---|---|---|
| Basic write operations | EXTS.P.CREATE | EXTS.P.CREATE Pkey | Creates a TairTS pkey. Fails if a pkey with the same name already exists. |
| EXTS.S.CREATE | EXTS.S.CREATE Pkey Skey [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 label2 val2 ...] | Creates an skey in a pkey. Auto-creates the pkey if it does not exist. Fails if an skey with the same name already exists. | |
| EXTS.S.ALTER | EXTS.S.ALTER Pkey Skey [DATA_ET time] | Modifies the metadata of an skey. Only DATA_ET can be modified. | |
| EXTS.S.ADD | EXTS.S.ADD Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Inserts a data point into an skey. Auto-creates the pkey or skey if they do not exist. Skey parameters take effect only when the skey is auto-created. | |
| EXTS.S.MADD | EXTS.S.MADD Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Inserts a data point into multiple skeys of a pkey in one call. Auto-creates the pkey or skeys if they do not exist. | |
| EXTS.S.INCRBY | EXTS.S.INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Inserts a data point by adding to (or subtracting from) the last data point value in the skey. The default initial value is 0. Auto-creates the pkey or skey if they do not exist. | |
| EXTS.S.MINCRBY | EXTS.S.MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Inserts data points into multiple skeys by incrementing or decrementing their last values. Auto-creates the pkey or skeys if they do not exist. | |
| EXTS.S.DEL | EXTS.S.DEL Pkey Skey | Deletes an skey and all its data points from a pkey. | |
| Basic read operations | EXTS.S.GET | EXTS.S.GET Pkey Skey | Returns the latest data point in an skey. |
| EXTS.S.INFO | EXTS.S.INFO Pkey Skey | Returns the metadata of an skey: data point count, latest timestamp and value, and label information. | |
| EXTS.S.QUERYINDEX | EXTS.S.QUERYINDEX Pkey filter1 [filter2 ...] | Returns skeys in a pkey that match the specified label filters. | |
| Aggregate operations | EXTS.S.RANGE | EXTS.S.RANGE Pkey Skey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] | Returns data points in an skey within a closed time range, with optional aggregation. |
| EXTS.S.MRANGE | EXTS.S.MRANGE Pkey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] [WITHLABELS] FILTER filter1 [filter2 ...] | Returns data points from multiple skeys that match label filters, within a closed time range. | |
| EXTS.P.RANGE | EXTS.P.RANGE Pkey fromTs toTs pkeyAggregationType pkeyTimeBucket [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] FILTER filter1 [filter2 ...] | Aggregates data points across skeys in a pkey. Skeys are first aggregated (as with EXTS.S.MRANGE), then the results are aggregated at the pkey level. | |
| Concurrent write operations | EXTS.S.RAW_MODIFY | EXTS.S.RAW_MODIFY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Sets the value of a data point at a specific timestamp. Auto-creates the pkey or skey if they do not exist. |
| EXTS.S.RAW_MMODIFY | EXTS.S.RAW_MMODIFY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Sets the values of multiple data points at specific timestamps in one call. Auto-creates the pkey or skeys if they do not exist. | |
| EXTS.S.RAW_INCRBY | EXTS.S.RAW_INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Modifies a data point at a specific timestamp by adding or subtracting a value. Auto-creates the pkey or skey if they do not exist. The default initial value is 0. | |
| EXTS.S.RAW_MINCRBY | EXTS.S.RAW_MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] | Modifies multiple data points at specific timestamps in one call. Auto-creates the pkey or skeys if they do not exist. | |
| General-purpose operations | DEL | DEL key [key ...] | Deletes one or more TairTS keys. |
Command syntax conventions:
UPPERCASE KEYWORD: command keyword_Italic text_: variable[options]: optional parameterA|B: mutually exclusive options...: the preceding parameter can be repeatedEXTS.P.CREATE
Time complexity| Item | Description |
|---|---|
| Syntax | EXTS.P.CREATE Pkey |
| O(1) | |
| Description | Creates a TairTS pkey. Fails if a pkey with the same name already exists. |
| Parameters | Pkey: the pkey name |
| Returns | OK on success; an error message otherwise |
Example:
EXTS.P.CREATE fooOutput:
OKEXTS.S.CREATE
| Item | Description |
|---|---|
| Syntax | EXTS.S.CREATE Pkey Skey [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 label2 val2 ...] |
| Time complexity | O(1) |
| Description | Creates an skey in the specified pkey. Auto-creates the pkey if it does not exist. Fails if an skey with the same name already exists. |
| Parameters | See below |
| Returns | OK on success; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
DATA_ET time | Relative expiration time of data points, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Size of a single chunk, in units of 16 bytes. Valid values: 1–256. Default: 256 (4 KB per chunk). When a chunk reaches capacity, a new chunk is created. See Best practices for tuning guidance. |
UNCOMPRESSED | Disables compression for the skey. By default, compression is enabled. |
LABELS label val ... | One or more label-value pairs attached to the skey. Example: LABELS sensor_id 1. |
Example:
EXTS.S.CREATE foo temperature DATA_ET 10000000 LABELS sensor_id 1Output:
OKEXTS.S.ALTER
| Item | Description |
|---|---|
| Syntax | EXTS.S.ALTER Pkey Skey [DATA_ET time] |
| Time complexity | O(1) |
| Description | Modifies the metadata of an skey. Only DATA_ET can be changed. |
| Parameters | See below |
| Returns | OK on success; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
DATA_ET time | New relative expiration time of data points, in milliseconds. Defaults to no expiration. |
Example:
EXTS.S.ALTER foo temperature DATA_ET 100000Output:
OKEXTS.S.ADD
| Item | Description |
|---|---|
| Syntax | EXTS.S.ADD Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(1) |
| Description | Inserts a data point into an skey. Auto-creates the pkey or skey if they do not exist. Skey parameters (DATA_ET, CHUNK_SIZE, UNCOMPRESSED, LABELS) take effect only when the skey is auto-created. |
| Parameters | See below |
| Returns | OK on success; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
ts | Unix timestamp of the data point, in milliseconds. Use * for the current server time. |
value | Data point value. Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time of data points, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. See EXTS.S.CREATE. |
UNCOMPRESSED | Disables compression for the skey. By default, compression is enabled. |
LABELS label val ... | One or more label-value pairs. Example: LABELS sensor_id 1. |
Example:
EXTS.S.ADD foo temperature * 30.5 DATA_ET 1000000 LABELS sensor_id 1Output:
OKEXTS.S.MADD
| Item | Description |
|---|---|
| Syntax | EXTS.S.MADD Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(n), where n is the number of skeys |
| Description | Inserts a data point into multiple skeys of a pkey in one call. Auto-creates the pkey or skeys if they do not exist. Skey parameters take effect only when the skey is auto-created. |
| Parameters | See below |
| Returns | OK for each skey on success; error messages otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
keynumber | Number of skey-ts-value records to insert |
Skey | The skey name |
ts | Unix timestamp, in milliseconds. Use * for the current server time. |
value | Data point value. Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
EXTS.S.MADD foo 3 temperature * 30.2 pressure * 2.05 distance * 0.5Output:
1) OK
2) OK
3) OKEXTS.S.INCRBY
| Item | Description |
|---|---|
| Syntax | EXTS.S.INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(1) |
| Description | Inserts a data point whose value is the last data point value plus value. A negative value subtracts from the last value. Auto-creates the pkey or skey if they do not exist. The default initial value is 0. |
| Parameters | See below |
| Returns | OK on success; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
ts | Unix timestamp, in milliseconds. Use * for the current server time. |
value | The increment (or decrement if negative) to apply to the last data point value. Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
First, add an initial data point:
EXTS.S.ADD foo temperature 1644310456023 30.0Then increment it:
EXTS.S.INCRBY foo temperature 1644372093031 2Output:
OKVerify the result:
EXTS.S.GET foo temperatureOutput:
1) (integer) 1644372093031
2) "32"EXTS.S.MINCRBY
| Item | Description |
|---|---|
| Syntax | EXTS.S.MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(n), where n is the number of skeys |
| Description | Inserts data points into multiple skeys by incrementing (or decrementing) the last value of each skey. Auto-creates the pkey or skeys if they do not exist. The default initial value is 0. |
| Parameters | See below |
| Returns | OK for each skey on success; error messages otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
keynumber | Number of skeys |
Skey | The skey name |
ts | Unix timestamp, in milliseconds. Use * for the current server time. |
value | The increment (or decrement if negative). Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
EXTS.S.MINCRBY foo 3 temperature * 0.2 pressure * -0.1 distance * 0.0Output:
1) OK
2) OK
3) OKEXTS.S.DEL
| Item | Description |
|---|---|
| Syntax | EXTS.S.DEL Pkey Skey |
| Time complexity | O(1) |
| Description | Deletes an skey and all its data points from a pkey. |
| Parameters | Pkey: the pkey name; Skey: the skey name |
| Returns | OK on success; an error message otherwise |
Example:
EXTS.S.DEL foo temperatureOutput:
OKEXTS.S.GET
| Item | Description |
|---|---|
| Syntax | EXTS.S.GET Pkey Skey |
| Time complexity | O(1) |
| Description | Returns the latest data point in an skey. |
| Parameters | Pkey: the pkey name; Skey: the skey name |
| Returns | The latest data point (timestamp and value) on success; nil if the pkey or skey does not exist; an error message otherwise |
Example:
EXTS.S.GET foo temperatureOutput:
1) (integer) 1644372730150
2) "32.2"EXTS.S.INFO
| Item | Description |
|---|---|
| Syntax | EXTS.S.INFO Pkey Skey |
| Time complexity | O(1) |
| Description | Returns the metadata of an skey, including data point count, latest timestamp and value, and label information. |
| Parameters | Pkey: the pkey name; Skey: the skey name |
| Returns | Skey metadata on success; nil if the pkey or skey does not exist; an error message otherwise |
Example:
EXTS.S.INFO foo temperatureOutput:
1) totalDataPoints // Number of data points
2) (integer) 1
3) maxDataPoints // Maximum data points the skey can hold (0 = no limit)
4) (integer) 0
5) maxDataPointsPerChunk // Data points per chunk
6) (integer) 32
7) dataPointsExpireTime // Relative expiration time in milliseconds (0 = no expiration)
8) (integer) 0
9) lastTimestamp // Timestamp of the latest data point
10) (integer) 1644389400996
11) chunkCount // Number of chunks in the skey
12) (integer) 1
13) lastValue // Value of the latest data point
14) (integer) 28
15) labels // Label information
16) 1) 1) "sensor_id"
2) "1"EXTS.S.QUERYINDEX
| Item | Description |
|---|---|
| Syntax | EXTS.S.QUERYINDEX Pkey filter1 [filter2 ...] |
| Time complexity | O(n), where n is the maximum number of sets involved in filter conditions |
| Description | Returns skeys in a pkey that match the specified label filters. |
| Parameters | See below |
| Returns | Matching skey names on success; nil if the pkey or skey does not exist; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
filter | Label filter conditions. At least one EQ, CONTAINS, or LIST_MATCH condition is required. See Index filtering syntax. |
Example:
EXTS.S.QUERYINDEX foo sensor_id=1Output:
1) "temperature"EXTS.S.RANGE
| Item | Description |
|---|---|
| Syntax | EXTS.S.RANGE Pkey Skey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] |
| Time complexity | O(n), where n is the number of chunks containing the queried data points |
| Description | Returns data points in an skey within a closed time range [fromTs, toTs], with optional aggregation. |
| Parameters | See below |
| Returns | Data points (or aggregation results) plus a continuation token; nil if the pkey or skey does not exist; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
fromTs | Start of the time range, as a Unix timestamp in milliseconds |
toTs | End of the time range, as a Unix timestamp in milliseconds. Use * for the current time. If toTs equals fromTs, the query returns data at that single point in time. |
MAXCOUNT count | Maximum number of data points to return. No default limit. Upper limit: 1,000,000. |
AGGREGATION aggregationType timeBucket | Aggregation type (e.g., MAX, AVG, SUM) and time bucket size in milliseconds (minimum: 1,000). Data within each bucket is aggregated and returned as a single value. The timestamp of each result is the start of its bucket. See Aggregation syntax. |
The response includes a continuation token as the last element:
0: all matching data points are returned1: some data points are not included. Use the timestamp of the last returned data point as the nextfromTsto retrieve the remaining data.
Example:
EXTS.S.RANGE foo test 1644459031662 * AGGREGATION AVG 10000 MAXCOUNT 2This returns the average value per 10-second bucket, limited to 2 results.
Output:
1) 1) 1) (integer) 1644459730000
2) "20.6"
2) 1) (integer) 1644459790000
2) "21.2"
2) (integer) 1The token 1 indicates that more data points exist beyond these 2 results.
EXTS.S.MRANGE
| Item | Description |
|---|---|
| Syntax | EXTS.S.MRANGE Pkey fromTs toTs [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] [WITHLABELS] FILTER filter1 [filter2 ...] |
| Time complexity | O(n), where n is the number of chunks containing the queried data points |
| Description | Returns data points from multiple skeys that match label filters, within a closed time range [fromTs, toTs]. |
| Parameters | See below |
| Returns | Matching skeys with their data points on success; nil if the pkey or skey does not exist; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
fromTs | Start of the time range, as a Unix timestamp in milliseconds |
toTs | End of the time range, as a Unix timestamp in milliseconds. Use * for the current time. |
MAXCOUNT count | Maximum number of data points to return per skey. Upper limit: 1,000,000. |
AGGREGATION aggregationType timeBucket | Aggregation type and time bucket size in milliseconds (minimum: 1,000). Results are returned at the start of each bucket. |
WITHLABELS | Includes label information in the output. Omitted by default. |
FILTER filter ... | Label filter conditions. At least one EQ, CONTAINS, or LIST_MATCH condition is required. See Index filtering syntax. |
Example:
EXTS.S.MRANGE foo 1644451031662 * AGGREGATION MAX 10000 WITHLABELS FILTER sensor_id=1Output:
1) 1) "temperature"
2) 1) 1) "sensor_id"
2) "1"
3) 1) 1) (integer) 1644481000000
2) "30"
4) (integer) 0
2) 1) "test"
2) 1) 1) "sensor_id"
2) "1"
3) 1) 1) (integer) 1644459730000
2) "20"
2) 1) (integer) 1644459790000
2) "20"
3) 1) (integer) 1644460620000
2) "29"
4) (integer) 0EXTS.P.RANGE
| Item | Description |
|---|---|
| Syntax | EXTS.P.RANGE Pkey fromTs toTs pkeyAggregationType pkeyTimeBucket [MAXCOUNT count] [AGGREGATION aggregationType timeBucket] FILTER filter1 [filter2 ...] |
| Time complexity | O(n), where n is the number of chunks containing the queried data points |
| Description | Aggregates data across skeys in a pkey. Skeys matching the filter are first aggregated (as in EXTS.S.MRANGE), then the skey results are aggregated at the pkey level. |
| Parameters | See below |
| Returns | Pkey-level aggregation results on success; nil if the pkey or skey does not exist; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
fromTs | Start of the time range, as a Unix timestamp in milliseconds |
toTs | End of the time range, as a Unix timestamp in milliseconds. Use * for the current time. |
pkeyAggregationType | Aggregation type for pkey-level aggregation. See Aggregation syntax. |
pkeyTimeBucket | Time bucket size for pkey-level aggregation, in milliseconds. Minimum: 1,000. |
MAXCOUNT count | Maximum number of data points to return per skey. Upper limit: 1,000,000. |
AGGREGATION aggregationType timeBucket | Aggregation type and time bucket for skey-level aggregation, in milliseconds. Minimum: 1,000. |
FILTER filter ... | Label filter conditions. At least one EQ, CONTAINS, or LIST_MATCH condition is required. See Index filtering syntax. |
Example:
EXTS.P.RANGE foo 1644451031662 * SUM 500000 AGGREGATION SUM 10000 FILTER sensor_id=1Output:
1) 1) 1) (integer) 1644459500000
2) "40"
2) 1) (integer) 1644460500000
2) "29"
3) 1) (integer) 1644481000000
2) "30"
2) (integer) 0EXTS.S.RAW_MODIFY
| Item | Description |
|---|---|
| Syntax | EXTS.S.RAW_MODIFY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(1) |
| Description | Sets the value of a data point at a specific timestamp in an skey. Auto-creates the pkey or skey if they do not exist. Skey parameters take effect only when the skey is auto-created. |
| Parameters | See below |
| Returns | OK on success; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
ts | Unix timestamp of the data point to update, in milliseconds |
value | New data point value. Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
EXTS.S.RAW_MODIFY foo temperature 1644310456023 31.5Output:
OKEXTS.S.RAW_MMODIFY
| Item | Description |
|---|---|
| Syntax | EXTS.S.RAW_MMODIFY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(n), where n is the number of skeys |
| Description | Sets the values of multiple data points at specific timestamps in one call. Auto-creates the pkey or skeys if they do not exist. |
| Parameters | See below |
| Returns | OK for each skey on success; error messages otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
keynumber | Number of skey-ts-value records to update |
Skey | The skey name |
ts | Unix timestamp of the data point to update, in milliseconds |
value | New data point value. Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
EXTS.S.RAW_MMODIFY foo 3 temperature 1644565954814 30.2 pressure 1644565954814 2.05 distance 1644565954814 0.5Output:
1) OK
2) OK
3) OKEXTS.S.RAW_INCRBY
| Item | Description |
|---|---|
| Syntax | EXTS.S.RAW_INCRBY Pkey Skey ts value [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(1) |
| Description | Modifies a data point at a specific timestamp by adding or subtracting a value. Auto-creates the pkey or skey if they do not exist. The default initial value is 0. |
| Parameters | See below |
| Returns | OK on success; an error message otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
Skey | The skey name |
ts | Unix timestamp of the data point to update, in milliseconds |
value | The increment (or decrement if negative). Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
First, add an initial data point:
EXTS.S.ADD foo temperature 1644310456 30.0Then apply an increment to the same timestamp:
EXTS.S.RAW_INCRBY foo temperature 1644310456 3.3Output:
OKVerify the result:
EXTS.S.GET foo temperatureOutput:
1) (integer) 1644310456
2) "33.3"EXTS.S.RAW_MINCRBY
| Item | Description |
|---|---|
| Syntax | EXTS.S.RAW_MINCRBY Pkey keynumber Skey ts value [Skey ts value ...] [DATA_ET time] [CHUNK_SIZE size] [UNCOMPRESSED] [LABELS label1 val1 ...] |
| Time complexity | O(n), where n is the number of data points |
| Description | Modifies multiple data points at specific timestamps in one call. Auto-creates the pkey or skeys if they do not exist. |
| Parameters | See below |
| Returns | OK for each skey on success; error messages otherwise |
Parameters:
| Parameter | Description |
|---|---|
Pkey | The pkey name |
keynumber | Number of skey-ts-value records to update |
Skey | The skey name |
ts | Unix timestamp of the data point to update, in milliseconds |
value | The increment (or decrement if negative). Must be a double-precision floating-point number. |
DATA_ET time | Relative expiration time, in milliseconds. Defaults to no expiration. |
CHUNK_SIZE size | Chunk size, in units of 16 bytes. Valid values: 1–256. Default: 256. |
UNCOMPRESSED | Disables compression. Enabled by default. |
LABELS label val ... | One or more label-value pairs. |
Example:
EXTS.S.RAW_MINCRBY foo 3 temperature 1644565954814 30.2 pressure 1644565954814 2.05 distance 1644565954814 0.5Output:
1) OK
2) OK
3) OKIndex filtering syntax
Use label filters to select skeys in EXTS.S.QUERYINDEX, EXTS.S.MRANGE, and EXTS.P.RANGE. At least one EQ, CONTAINS, or LIST_MATCH condition is required.
| Filter expression | Logic | Description |
|---|---|---|
L = V | EQ | Label L equals V |
L != | CONTAINS | Label L exists (is not null) |
L = (v1,v2,...) | LIST_MATCH | Label L equals one of the listed values |
L != V | NOEQ | Label L does not equal V |
L = | NOCONTAINS | Label L does not exist (is null) |
L != (v1,v2,...) | LIST_NOTMATCH | Label L does not match any listed value |
Aggregation syntax
Aggregation groups data points within each time bucket defined by timeBucket and computes a single value per bucket. The following aggregation types are supported:
| Type | Returns |
|---|---|
MAX | Maximum value |
MIN | Minimum value |
AVG | Average value |
SUM | Sum of all values |
FIRST | First value in the bucket |
LAST | Last value in the bucket |
RANGE | Difference between maximum and minimum values |
COUNT | Number of values |
STD.P | Population variance |
STD.S | Sample variance |
VAR.P | Population standard deviation |
VAR.S | Sample standard deviation |
FAQ
Why is the default CHUNK_SIZE small on some Tair DRAM-based instances compatible with Redis 5.0?
Starting with version 25.2.0.0, CHUNK_SIZE defaults to 256. In earlier versions, it defaults to 32.