Slow Query Question/
I need to know the reasons why the below query is slow ..takes more than a min...I have total 4K records
<cfquery datasource="#attr.DSN#" name="SearchRes">
select a.*, c.comments
from ops$new.network_event a,
( SELECT MAX( record_number ), comments, event_number
FROM ops$new.ne_comment
GROUP BY comments, event_number ) c
where
1 = 1
<cfif attr.problem neq "" or attr.node neq "" or attr.lob neq "">
And a.event_number in
(
select distinct e.event_number
from
ops$new.network_event e
, ops$new.ne_node n
, ops$new.ne_problem p
, ops$new.ne_lob l
where
1 = 1 And
e.event_number = p.event_number
and e.event_number = n.event_number
and e.event_number = l.event_number
<cfif attr.node neq "" and trim(attr.node) neq "All">
And n.node in (#ListQualify(attr.node, "'")#)
</cfif>
<cfif attr.problem neq "">
And p.problem_code in (#attr.problem#)
</cfif>
<cfif attr.lob neq "">
And l.lob in (#ListQualify(attr.lob, "'")#)
</cfif>
)
</cfif>
And a.event_number = c.event_number(+)
<cfif attr.tick neq "">
And lower(TICKET_NUMBER) like lower('#attr.tick#%')
</cfif>
<cfif attr.status neq "">
And status_code = #attr.status#
</cfif>
<!---StartDateTime--->
<cfif attr.start_date0 neq "" and attr.start_date1 neq "">
And Start_date between #CreateODBCDateTime(attr.start_date0)# And #CreateODBCDateTime(attr.start_date1)#
<cfelseif attr.start_date0 neq "">
And Start_date <= #CreateODBCDateTime(attr.start_date0)#
<cfelseif attr.start_date1 neq "">
And Start_date <= #CreateODBCDateTime(attr.start_date1)#
</cfif>
<!---EndDateTime--->
<cfif attr.end_date0 neq "" and attr.end_date1 neq "">
And end_date between #CreateODBCDateTime(attr.end_date0)# And #CreateODBCDateTime(attr.end_date1)#
<cfelseif attr.end_date0 neq "">
And end_date <= #CreateODBCDateTime(attr.end_date0)#
<cfelseif attr.end_date1 neq "">
And end_date <= #CreateODBCDateTime(attr.end_date1)#
</cfif>
<cfif attr.division neq "" and trim(attr.division) neq "All">
And lower(trim(division)) = lower('#trim(attr.division)#')
</cfif>
<cfif attr.hub neq "" and trim(attr.hub) neq "All">
And trim(hub) = '#trim(attr.hub)#'
</cfif>
<cfif attr.ack neq "" and attr.ack eq "Y">
And ACKNOWLEDGE_EID is not null
<cfelseif attr.ack neq "" and attr.ack eq "N">
And ACKNOWLEDGE_EID is null
</cfif>
</cfquery>
