谁能帮我优化这个查询?
SELECT distinct t.designation,
(SELECT sum(time_to_sec(timediff(outtime,intime)))
FROM onlinetime where datecreated BETWEEN '2012-01-01 00:00:01'
AND '2012-12-31 23:59:59' and designation=t.designation) as totsec
FROM onlinetime t;
我正在尝试从在线时间表中获取名称和秒数。它只有 8000 条记录,但上述查询需要大量时间来执行。有没有其他方法可以优化这个?