我有一张超过 660 万行的表格。
我有一个名为 trip_id
的字段,其类型为 BINARY(16)
。我觉得查询太慢了(0.2 秒
)。这个查询大约每 3 秒运行一次。
在做出任何愚蠢的操作之前,我想知道如果将 trip_id
索引的大小从 full 减小到 12,是否会有所改善?
如果我尝试进一步调整我的查询,是否会有所改善?
谢谢
编辑:
查询:
SELECT stop_times.stop_id
FROM trips
LEFT JOIN stop_times ON trips.trip_id = stop_times.trip_id
WHERE trips.route_id = '141'
GROUP BY stop_times.stop_id
ORDER BY trips.trip_headsign ASC,
stop_times.stop_sequence ASC
trip_id BINARY(16)
route_id SMALLINT(3)
trip_headsign VARCHAR(50)
stop_sequence SMALLINT(3)
查询的解释:
![Explain of the query](https://istack.dev59.com/H5T1C.webp)