I have the following query that is consistently timing out for the last few weeks. It had ran perfectly fine since 2019, previously. I know the query needs to be optimized, but I don't see anything egregious besides maybe changing the subkey check. I did a TOP 50 PERCENT and even 25 Percent, all timed out. Query without the top is
select s.subscriberkey as Salesforce_ID,CAST (MAX(s.EventDate) AS DATE) as Last_Marketing_Email_Sent
from
_Sent s with(nolock)
inner join [DE] a on a.Salesforce_ID=s.subscriberkey
inner join _Job j with(nolock) on s.jobid = j.jobid
where j.sendclassificationtype = 'Default Commercial' and (s.SubscriberKey NOT LIKE '%-%') and (s.SubscriberKey NOT LIKE '%@%') and EventDate >= DATEADD(dd, -30, CURRENT_TIMESTAMP)
Group by s.subscriberkey