Rewrite this query into:
SELECT ... (do the calculation with t1.trade_timesamp and t2.trade_timestamp) ...
FROM t_course_live t1
LEFT JOIN t_course_live t2
ON t1.id = t2.id+1
WHERE
t1.trade_timestamp>= '2014-04-28'
AND t1.trade_timestamp < '2014-04-29'
and t2.trade_timestamp>= '2014-04-28'
AND t2.trade_timestamp < '2014-04-29'
Using DATE(column)
function and joinin with a subquery prevents MySql from using indexes.
I assume that an index on trade_timestamp
has already been created.
=========== EDIT =========================
There is a subtle mistake in my previous answer.
The above query is not equivalent to the orginal query, because these conditions:
and t2.trade_timestamp>= '2014-04-28'
AND t2.trade_timestamp < '2014-04-29'
converts the query from left join into regular join.
A correct query is:
SELECT ... (do the calculation with t1.trade_timesamp and t2.trade_timestamp) ...
FROM t_course_live t1
LEFT JOIN t_course_live t2
ON t1.id = t2.id+1
AND t2.trade_timestamp>= '2014-04-28'
AND t2.trade_timestamp < '2014-04-29'
WHERE
t1.trade_timestamp>= '2014-04-28'
AND t1.trade_timestamp < '2014-04-29'