How to Use the Data Retention Window

How to Use the PipelineDB CV TTL Function

You can follow these steps to learn how you can use the PipelineDB CV TTL function.

Creating a Data Stream and Getting CV TTL Ready

First, you’ll want to create a stream (that is, more specifically, define the data format) using the following command:

CREATE STREAM s1 (id int, info text, crt_time timestamp default now());
CREATE CONTINUOUS VIEW cv1 WITH (ttl = '1 min', ttl_column = 'crt_time') AS  
SELECT id,info,crt_time FROM s1;
activate cv1;

Testing How the Function Works

Next, in our little learning process, let’s conduct a test. To do so follow these steps. First, write data into a stream.

pipeline=# insert into s1 values (1,'test',now());  
INSERT 0 1
pipeline=# select * from cv1;  
id | info | crt_time
----+------+----------------------------
1 | test | 2017-06-12 17:11:45.774904
(1 row)
pipeline=# select set_ttl('cv1', '10 second', 'crt_time');  
set_ttl
---------
(10,3)
(1 row)

References

Original Source

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com