In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `stop_times` ADD INDEX `stop_times_idx_stop_id` (`stop_id`);
SELECT
DISTINCT stop_times.trip_id
FROM
stop_times
WHERE
stop_times.stop_id = 1538
AND stop_times.stop_id = 1540