diff --git a/lib/frequencies.js b/lib/frequencies.js index f4c8f1e..3ae3e8d 100644 --- a/lib/frequencies.js +++ b/lib/frequencies.js @@ -74,13 +74,15 @@ SET frequencies_row = t.frequencies_row FROM ( SELECT -- order by all columns so that we don't implicitly depend on the file's order - (row_number() OVER (PARTITION BY trip_id, exact_times ORDER BY start_time, end_time, headway_secs))::integer AS frequencies_row, + (row_number() OVER (PARTITION BY trip_id, start_time ORDER BY end_time, headway_secs, exact_times))::integer AS frequencies_row, trip_id, start_time FROM "${opt.schema}".frequencies ) AS t -- self-join +-- frequencies' primary is just (trip_id, start_time) +-- see also https://github.com/google/transit/issues/514 WHERE frequencies.trip_id = t.trip_id -AND frequencies.exact_times = t.exact_times; +AND frequencies.start_time = t.start_time; CREATE INDEX ON "${opt.schema}".frequencies (trip_id); CREATE INDEX ON "${opt.schema}".frequencies (exact_times);