Scenario: There is a water meter that collects its readings every 15 minutes and writes the data into WATER-METER1
Now it is necessary to perform downsampling on the collected data (taking the maximum value of each water meter every hour).
When data is written, its maximum reading can be immediately seen.
Steps:
--1 Create a standard PostgreSQL table
CREATE TABLE WATER_METER1
(
TIME TIMESTAMPTZ NOT NULL,
METER_CODE TEXT NOT NULL,
DQLJLCC DOUBLE PRECISION NULL
);
--2 Convert the table to a hypertable.
SELECT CREATE_HYPERTABLE('WATER_METER1','time');
--3 CREATE MATERIALIZED VIEW
CREATE MATERIALIZED VIEW WATER_CONSUME_HOUR
WITH (TIMESCALEDB.CONTINUOUS) AS
SELECT
TIME_BUCKET('1 hour', "time") AS RECODE_TIME,
METER_CODE,
MAX(DQLJLCC) AS MAX_READING
FROM WATER_METER1
GROUP BY RECODE_TIME, METER_CODE;
The data is continuously written to the WATER-METER1 table, while WATER-CONSUME_HOUR is empty
May I ask, what is the reason for this?