我有一个查询,向我报告添加记录的时间。我还在这个查询中跟踪添加到数据库中的图像的大小。据我所见,它看起来像是从链接服务器返回整个图像,然后计算大小。有没有一种简单的方法可以在链接的另一端计算大小,以便更快地返回?
SELECT
[Date] = CAST(DATEADD(DAY,-@DaysBack,GETDATE()) AS DATE)
,NOTES = N.RPMID
,TimeTaken = DATEDIFF("SECOND",SN.PickedUpDate,SN.ProcessedDate)
,PictureSize = SUM(CAST(DATALENGTH(SI.[Image])AS BIGINT))
,RecordsAdded = CAST(COUNT(*) AS BIGINT)
FROM
DBServer1.DB1.dbo.Notes AS N WITH (NOLOCK)
INNER JOIN DBServer1.DB1.dbo.NoteDistribution AS ND WITH (NOLOCK) ON N.Notes=ND.Notes
INNER JOIN dbo.Submission_Notes AS SN WITH (NOLOCK) ON SN.RetailPlanGuid=N.RPMID
LEFT JOIN DBServer1.DB1.dbo.SavedImage SI WITH (NOLOCK) ON SI.Notes=N.Notes
WHERE
1=1
AND N.RecordStampWhenAdd > CAST(GETDATE()-@DaysBack AS DATE)
AND N.RecordStampWhenAdd < CAST(GETDATE()-@DaysBack+1 AS DATE)
AND DATEDIFF("SECOND",SN.PickedUpDate,SN.ProcessedDate) > 0
GROUP BY
N.RPMID
,DATEDIFF("SECOND",SN.PickedUpDate,SN.ProcessedDate)
有问题的部分是返回的图片大小。我希望其中的计算在存储数据的服务器上完成,并将数字返回给我。在这方面的任何帮助都会很棒。谢谢。