You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sql-create-stream.md
+31-6Lines changed: 31 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,18 @@
2
2
3
3
[Stream](/working-with-streams) is a key [concept](/glossary) in Timeplus. All data lives in streams, no matter static data or data in motion. We don't recommend you to create or manage `TABLE` in Timeplus.
@@ -21,6 +24,10 @@ Stream creation is an async process.
21
24
22
25
If you omit the database name, `default` will be used. Stream name can be any utf-8 characters and needs backtick quoted if there are spaces in between. Column name can be any utf-8 characters and needs backtick quoted if there are spaces in between.
23
26
27
+
### Mutable Stream
28
+
29
+
Mutable Streams are available in Timeplus Enterprise. Guide: [CREATE MUTABLE STREAM](/sql-create-mutable-stream)
30
+
24
31
### Versioned Stream
25
32
26
33
[Versioned Stream](/versioned-stream) allows you to specify the primary key(s) and focus on the latest value. For example:
The default `version_column` is `_tp_time`. For the data with same primary key(s), Proton will use the ones with maximum value of `version_column`. So by default, it tracks the most recent data for same primary key(s). If there are late events, you can use specify other column to determine the end state for your live data.
@@ -131,3 +134,25 @@ This is an advanced setting. Default value is `hybrid` to use both a streaming s
131
134
It can be:
132
135
*`streaming`: Use only streaming storage, together with settings `logstore_codec`, `logstore_retention_bytes`, `logstore_retention_ms`.
133
136
*`memory`: put data in memory only, mainly for testing.
137
+
138
+
## TTL (Time-To-Live) {#ttl}
139
+
140
+
The [logstore_retention_bytes](#logstore_retention_bytes) and [logstore_retention_ms](#logstore_retention_ms) settings control the maximum size and time to keep the streaming storage. The historical storage for the stream is controlled by the TTL expression.
141
+
142
+
Syntax:
143
+
```sql
144
+
TTL time_column + interval
145
+
```
146
+
147
+
For example, `TTL _tp_time + INTERVAL 1 DAY` will delete rows older than one day, `TTL _tp_time + INTERVAL 7 DAY` will delete rows older than one week.
148
+
149
+
For [S3 Tried Storage](/tiered-storage#create-a-stream-with-the-policy), you can also specify when the cold data will be moved to S3. For example:
150
+
```sql
151
+
CREATE STREAM my_stream (
152
+
id uint32,
153
+
name string,
154
+
age uint8
155
+
)
156
+
TTL to_start_of_day(_tp_time) + interval 7 day to volume 'cold'
0 commit comments