Hi there,
Is anyone tell me why my query too slow????????????????
unix_to_date is user-defined function .
la_max_timeand start_time are unix format - number
select a.nmt_id,a.la_max_date,a.la_max,
sum(a.CurCNE),
sum(a.N70),
sum(a.N80),
sum(a.N90)
from
(select ne.nmt_id ,trunc(unix_to_date(la_max_time))la_max_date,ne.la_max,
(case when to_number(to_char((unix_to_date(la_max_time)),'hh24mi'))>=2300
or to_number(to_char((unix_to_date(la_max_time)),'hh24mi')) <=600 then 1 else 0 end )CurCNE,
(case when (la_max)/10>=70 then 1 else 0 end) N70,
(case when (la_max)/10>=80 then 1 else 0 end) N80,
(case when (la_max)/10>=90 then 1 else 0 end) N90
from ne
where track_id <>0 and
trunc(unix_to_date(la_max_time)) between to_date('1/01/2006','dd/mm/yyyy') and to_date('1/02/2006','dd/mm/yyyy') and
to_char(unix_to_date(la_max_time),'yyyymmddhh24') in
(select to_char(unix_to_date(start_time),'yyyymmddhh24')
from nc
where climate_type = 1 and nc.nmt_id = ne.nmt_id and
trunc(unix_to_date(la_max_time)) = trunc(unix_to_date(start_time))))a
group by a.nmt_id,a.la_max_date,a.la_max
regards and thanks
nat
Is anyone tell me why my query too slow????????????????
unix_to_date is user-defined function .
la_max_timeand start_time are unix format - number
select a.nmt_id,a.la_max_date,a.la_max,
sum(a.CurCNE),
sum(a.N70),
sum(a.N80),
sum(a.N90)
from
(select ne.nmt_id ,trunc(unix_to_date(la_max_time))la_max_date,ne.la_max,
(case when to_number(to_char((unix_to_date(la_max_time)),'hh24mi'))>=2300
or to_number(to_char((unix_to_date(la_max_time)),'hh24mi')) <=600 then 1 else 0 end )CurCNE,
(case when (la_max)/10>=70 then 1 else 0 end) N70,
(case when (la_max)/10>=80 then 1 else 0 end) N80,
(case when (la_max)/10>=90 then 1 else 0 end) N90
from ne
where track_id <>0 and
trunc(unix_to_date(la_max_time)) between to_date('1/01/2006','dd/mm/yyyy') and to_date('1/02/2006','dd/mm/yyyy') and
to_char(unix_to_date(la_max_time),'yyyymmddhh24') in
(select to_char(unix_to_date(start_time),'yyyymmddhh24')
from nc
where climate_type = 1 and nc.nmt_id = ne.nmt_id and
trunc(unix_to_date(la_max_time)) = trunc(unix_to_date(start_time))))a
group by a.nmt_id,a.la_max_date,a.la_max
regards and thanks
nat