加入后的连接或加入后的过滤之间的性能是否更好? 示例
...
INNER JOIN
(select * from dbo.tblCMEvalEmail
where dbo.tblCMEvalEmail.EmailSentDate BETWEEN '2013-05-16 00:00:00'
AND '2013-06-01 23:59:59')
as TCMEvalEmail ON dbo.tblTSAEmail.TSAEmail = TCMEvalEmail.EmailSenderEmail
INNER JOIN
(select * from dbo.tblCMEvalEmailInfo
where dbo.tblCMEvalEmailInfo.EmailCMFacingDate BETWEEN '2013-05-16 00:00:00'
AND '2013-06-01 23:59:59')
as TEmailInfo ON TCMEvalEmail.EmailID = TEmailInfo.EmailID
或
INNER JOIN dbo.tblCMEvalEmail
ON dbo.tblTSAEmail.TSAEmail = dbo.tblCMEvalEmail.EmailSenderEmail
INNER JOIN dbo.tblCMEvalEmailInfo
ON dbo.tblCMEvalEmail.EmailID = dbo.tblCMEvalEmailInfo.EmailID
WHERE
dbo.tblCMEvalEmail.EmailSentDate BETWEEN '2013-05-16 00:00:00'
AND '2013-06-01 23:59:59'
AND dbo.tblCMEvalEmailInfo.EmailCMFacingDate BETWEEN '2013-05-16 00:00:00'
AND '2013-06-01 23:59:59'
答案 0 :(得分:0)
这取决于您拥有的方案和数据。经验法则是获得最少的所需数据并进一步过滤。根据数据,有时JOIN后跟filer可能会更好,但在不同的数据集上,反之亦然可能更好。因此,您需要通过运行查询和衡量性能来确定哪一个对您有所帮助。