这是我的查询,任何人都可以看到任何方式使这种效率更高,因此它不超时?我正在使用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'
)
)
谢谢!不幸的是,Exacttarget使用的SQL版本不允许使用变量。我确实收到了一些建议,希望在WHERE子句之上打开并单击数据,以便我可以尝试查看是否可以使其工作。欣赏你看着这个虽然! – Lukacko
我想知道是否会出现这种情况 - 对ExactTarget不熟悉,但我带了一份传单。如果ExactTarget允许参数化查询,您可以单独计算测试日期并将其传入。但是,如果您只有我的第二个建议,而将日期计算保持一致,则可能仍会看到perf性能的提高。 –