Votre requête est un moyen de faire une moyenne mobile :
SELECT t.*,
(select avg(speed) from tbl tt where tt.timestamp <= t.timestamp) as avg
FROM tbl t;
L'alternative est d'utiliser des variables :
select t.*, (sum_speed / cnt) as running_avg_speed
from (select t.*, (@rn := @rn + 1) as cnt, (@s := @s + speed) as sum_speed
from tbl t cross join
(select @rn := 0, @s := 0) params
order by timestamp
) t;
Un index sur tbl(timestamp)
devrait encore améliorer les performances.