Postgres/TimescaleDB: Difference between revisions
Appearance
< Postgres
mNo edit summary |
|||
| Line 21: | Line 21: | ||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
INSERT INTO sensor_data (time, topic, value) | INSERT INTO sensor_data (time, topic, value) VALUES ( | ||
VALUES ( | |||
now(), | now(), | ||
'{{{ msg.topic }}}', | '{{{ msg.topic }}}', | ||
Revision as of 19:03, 29 September 2024
Setup
CREATE TABLE sensor_data (
time TIMESTAMPTZ NOT NULL,
topic TEXT,
value DOUBLE PRECISION
);
SELECT create_hypertable('sensor_data', 'time');
Insert data via Node-RED
INSERT INTO sensor_data (time, topic, value) VALUES (
now(),
'{{{ msg.topic }}}',
'{{{ msg.payload }}}'
);
Get table size
SELECT hypertable_size('sensor_data');