create potential arrival hypertable
This commit is contained in:
parent
f2bf0bd150
commit
aa8cbd9bc5
|
@ -195,6 +195,10 @@ CREATE TABLE potential_arrivals(
|
||||||
distance decimal NOT NULL
|
distance decimal NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SELECT create_hypertable('potential_arrivals', 'measured_at', chunk_time_interval => INTERVAL '10 minutes');
|
||||||
|
CREATE INDEX potential_arrivals_measures ON potential_arrivals (bus_id, measured_at DESC);
|
||||||
|
CREATE INDEX potential_arrivals_spatial ON potential_arrivals USING GIST (bus_coords);
|
||||||
|
|
||||||
CREATE FUNCTION check_near_stop() RETURNS trigger LANGUAGE plpgsql AS $$
|
CREATE FUNCTION check_near_stop() RETURNS trigger LANGUAGE plpgsql AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO potential_arrivals (raw_pos_id, bus_id, bus_coords, measured_at, stop_id, distance)
|
INSERT INTO potential_arrivals (raw_pos_id, bus_id, bus_coords, measured_at, stop_id, distance)
|
||||||
|
|
Loading…
Reference in New Issue