I’m running TSDB with PostGIS and with loads of GPS data. I’ve been using Hypertables + Hierarchical Continuos Aggregates to reduce the amount of data being queried for large time ranges.
There are some issues with noise in the GPS data where there are large jumps in the position due to GPS lock error. This doesn’t happen often but is very noticeable when a device jumps 1000 km out of a relatively smooth trajectory. I was wondering whether there is a good way to include filtering in the generation of aggregates. Something like:
CREATE MATERIALIZED VIEW gps.daily_pos_cagg WITH
(timescaledb.continuous )
AS
SELECT gps.gps_id,
time_bucket('12h'::interval, gps.time) AS bucket,
last(gps.geom, gps.time) AS geom,
last(gps.data, gps.time) AS data,
FROM gps
WHERE <make sure distance less than something reasonable>
AND <make sure data jumps less than something reasonable>
GROUP BY gps.gps_id, bucket WITH NO DATA;
Can I use Lead/Lag window functions in the definition of continous aggregates? Or some other way to make sure that there are no big jumps in distance/time/data or whatever other noisy parameter I need to low pass filter on?