1

これが私のクエリです。タイムアウトしないように、これをより効率的にする方法を誰でも見ることができますか? Exacttarget (Salesforce Marketing Cloud) を使用しています。30 分のタイムアウト制限があります。物事を動かそうとしましたが、常にエラーのようです。私は SQL の初心者ですが、先週はかなり苦労しました。私の質問は以下です。ありがとう!

SELECT DISTINCT c.Email,  c.FName
FROM ENT.Contacts c WITH(NOLOCK)
INNER JOIN ENT.RegistrationData r WITH(NOLOCK)
ON c.Email  =  r.RegistrationContactEmail
LEFT Join ENT._Subscribers s  WITH(NOLOCK)
ON c.Email =  s.SubscriberKey
AND s.status NOT IN ('unsubscribed','held')

WHERE

(
    (
        (
            (
                r.RegistrationEmailOptStatus  =  '1' AND
                r.RegistrationEventType  =  'Wedding' AND
                r.RegistrationEventRole IN ('Bride','Other','Bridesmaid','Mother Of the Bride') AND
                r.RegistrationCountry IN ('USA') AND
                r.RegistrationEventDate < '2014-05-31'
            )

            OR

            (
                r.RegistrationEmailOptStatus  =  '1' AND
                r.RegistrationEventType  =  'Prom' AND
                r.RegistrationEventRole ='Prom' AND
                r.RegistrationCountry IN ('USA') AND
                r.RegistrationEventDate BETWEEN '2014-01-01' AND '2015-12-31'
            )
        )

        AND

        (
            (
                c.Email IN
                (
                    SELECT DISTINCT 
                        s.SubscriberKey AS Email
                    FROM 
                        _Open s
                    WHERE
                        datediff(mm,s.EventDate, getdate()) <= 3
                )
            )
            OR
            (
                c.Email IN
                (
                    SELECT DISTINCT 
                        s.SubscriberKey AS Email
                    FROM 
                        _Click s
                    WHERE
                        datediff(mm,s.EventDate, getdate()) <= 3
                )
            )
        )

    )

    OR

    (
        r.RegistrationEmailOptStatus  =  '1' AND
        r.RegistrationEventType  =  'Wedding' AND
        r.RegistrationEventRole IN ('Bride','Other','Bridesmaid','Mother Of the Bride') AND
        r.RegistrationCountry IN ('USA') AND
        r.RegistrationEventDate BETWEEN '2015-05-01' AND '2015-05-31'
    )
)
4

2 に答える 2