Timestamp/hstore query?
| От | Brent Wood |
|---|---|
| Тема | Timestamp/hstore query? |
| Дата | |
| Msg-id | SY3PR01MB081006506D32FA0D7823B239A14E9@SY3PR01MB0810.ausprd01.prod.outlook.com обсуждение исходный текст |
| Ответы |
Re: Timestamp/hstore query?
|
| Список | pgsql-general |
Hi,
I have a database with instrument readings stored in hstore key-value pairs, so a record has a timestamp attribute and an hstore attribute with all the sensor readings for that time. The key identifies the sensor, the value is the reading.
Not all sensors have a reading at every timestamp.
Timestamps are 1 sec intervals.
The db uses Timescaledb hypertables to partition the data
How can I select the LAST (hstore) value for each instrument (hstore key) at one minute intervals. So I get an output of 1 minute timestamps & an hstore containing the last key-value pairs for each key in present in that 1 minute interval.
Essentially this provides a snapshot saying "at this time (1 min interval) the latest (current) reading for each sensor. was this value"
I'm OK with a user defined pl/pgsql function if this is the best approach.
Thanks
Brent Wood
Principal Technician, Fisheries
NIWA
DDI: +64 (4) 3860529
Principal Technician, Fisheries
NIWA
DDI: +64 (4) 3860529
![]() ![]() |
В списке pgsql-general по дате отправления:

