Skip to content

Commit 29edb2a

Browse files
committed
queryScheduleStopTimes(): use subquery instead of join when querying trip stop_times ⚡️
Decreasing the query p50 query time from ~2 minutes to ~150ms. 🚀
1 parent e5bd5aa commit 29edb2a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/query-schedule-stop-times.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ SELECT
6464
ad.stop_sequence,
6565
ad.t_arrival, ad.t_departure
6666
FROM arrivals_departures ad
67-
JOIN st ON (
68-
st."date" = ad."date"
69-
AND st.trip_id = ad.trip_id
70-
)
67+
WHERE ad."date" = (SELECT "date" FROM st)
68+
AND ad.trip_id = (SELECT trip_id FROM st)
7169
LIMIT $7
7270
`
7371
values.push(

0 commit comments

Comments
 (0)