私は時には15秒、場合によっては1分かかるSQLクエリを持っています。 質問を軽くする方法を教えてください。SQLリクエストの実行に多くの時間がかかります
SELECT TOP 100
u.firstName,
u.id as userID,
ueh.targetID,
ueh.opened,
ueh.emailID,
u.phone,
u.gender
FROM dbo.Students u
INNER JOIN dbo.tblEmailHistory ueh
ON ueh.studentID = u.ID
WHERE (CONVERT(date,DATEADD(day,6,ueh.sDate))=CONVERT(date,getdate()))
AND IsNull(u.firstName, '') != ''
AND IsNull(u.email, '') != ''
AND IsNull(u.phone, '') != ''
AND ueh.status = 'sent'
AND ueh.reject_reason = 'null'
AND ueh.targetID = 28
AND ueh.opened = 0
AND u.deleted = 0
AND NOT EXISTS (SELECT ush.smsSendFullDate, ush.studentID FROM dbo.UsersSmsHistory ush WHERE u.id = ush.studentID AND DATEDIFF(DAY,ush.smsSendFullDate,GETDATE()) = 0)
実行計画を既に確認しましたか? –