sql performance when executing huge table -


i found sql file @ workplace

declare   m_depature_time    varchar;  begin    select min(cast(to_char(i.departuredate,'dd-mon-yyyy') varchar) ||' '|| i.departuretime) deptime   m_depature_time   myschema.flightinfosv    upper(i.inout) = upper(m_inout)   ,  i.r_id= m_resconfirmid;    return m_depature_time;  end; 

the problem why script take more time(more 15 mins) execute in thousands of records table.the table(resflightinfosv) consist of @ least 50,000 records.although use indexes both 'inout' , 'r_id' , when execute 1000 limit take time.where places need change script?

thanks in advance!

you can add multi-column index on departuredate , departuretime , try this; extract minimum date first , then, date, select smallest hour. don't think following code work "as-is" cause i'm not able test main idea :)

declare   m_depature_date    date,  m_depature_time    varchar;  begin    select min(i.departuredate) depdate   m_depature_date   myschema.flightinfosv   upper(i.inout) = upper(m_inout)   ,  i.r_id= m_resconfirmid;    select to_char(i.departuredate,'dd-mon-yyyy') ||' '|| min(i.departuretime) deptime   m_depature_time   myschema.flightinfosv    upper(i.inout) = upper(m_inout)   ,  i.r_id= m_resconfirmid   ,  i.departuredate = m_depature_date    return m_depature_time;  end; 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -