Have large table (Sybase) rows = 6276225. I'm pulling call status and my query is very slow.
In effect what I’m trying to do is pull data for any event after my variable. While querying for just one acct, the query takes around 15 sec, anything larger and my query runs forever.
How can I speed up my query?
declare
@RSP varchar (2)
SET
@RSP = 'WN'
select
a.contact_list_name,
a.agent_login_name,
a.account_number,
a.ov_phone_number,
a.time_of_contact,
a.response_status
from table a
where a.time_of_contact >=
(SELECT
b.time_of_contact
FROM table b
WHERE a.account_number = b.account_number
and a.ov_phone_number = b.ov_phone_number
and a.time_of_contact >= b.time_of_contact
and b.contact_list_name ='Prime_list'
and b.response_status = @RSP)