Otra opcion para select (select)as fin from table1

¿Puede existir alguna otra manera de hacer que esta consulta se ejecute más rápido? Actualmente me lleva 15 minutos...

select host_object_id, fecha,
sum(time_to_sec(time(if(state_type = 1,if(state > 0,timediff(if(state_type = 1,if(state > 0,ifnull((select h2.inicio
from hostsayer as h2
where h2.inicio > h1.inicio and h1.host_object_id = h2.host_object_id
order by inicio asc limit 1),'23:59:49'),0),0),inicio),0),0)))) as secsmedown
from hostsayer as h1
group by host_object_id

Los registros del hostsayer son 83400.

Añade tu respuesta

Haz clic para o