我有7秒鐘內運行的查詢,在本地SQL Server 2008 R2實例上(非快速)生成12,094條記錄。但是,Sql Server Express實例需要38秒。這可能只是本地8GB Hyper-V機器和具有一半內存的遠程GoGrid機器之間的區別。XML查詢問題 - 在一臺服務器上性能不錯,另一臺服務器性能很差
我的問題是我在做什麼明顯效率低下?
查詢:
declare @FromTimestamp datetime = '2012-02-01'
declare @ToTimestamp datetime = '2012-02-22'
DECLARE @to datetime = DATEADD(dd, 1, @ToTimestamp)
SELECT
Data.value('(/LendingTreeAffiliateRequest/Request/@AppID)[1]', 'varchar(50)') AS AppID,
Data.value('(/LendingTreeAffiliateRequest/Request/@type)[1]', 'varchar(50)') AS [Type],
[Timestamp],
Data.value('(/LendingTreeAffiliateRequest/@affid)[1]', 'varchar(50)') AS CDNumber,
Data.value('(/LendingTreeAffiliateRequest/Request/SourceOfRequest/VisitorIPAddress)[1]', 'varchar(50)') AS IP,
Data.value('(/LendingTreeAffiliateRequest/Request/SourceOfRequest/LendingTreeAffiliateEsourceID)[1]', 'varchar(50)') AS ESourceID,
Data.value('(/LendingTreeAffiliateRequest/Request/Applicant/State)[1]', 'char(2)') AS [State],
Data.value('(/LendingTreeAffiliateRequest/Request/Applicant/DateOfBirth)[1]', 'varchar(20)') AS DateOfBirth,
Data.value('(/LendingTreeAffiliateRequest/Request/Applicant/EmailAddress)[1]', 'varchar(255)') AS Email,
Data.value('(/LendingTreeAffiliateRequest/Request/Applicant/IsVeteran)[1]', 'char(1)') AS IsVeteran,
Data.value('(/LendingTreeAffiliateRequest/Request/Applicant/CreditHistory/CreditSelfRating)[1]', 'varchar(50)') AS Credit
FROM
WebLogEntry wle
INNER JOIN EventType et on wle.EventTypeId=et.Id
INNER JOIN [EventData] ed on wle.EventDataId=ed.Id
WHERE
(et.Id=2)
AND (Data.exist('/LendingTreeAffiliateRequest/Request/@AppID')=1)
AND ([Timestamp] BETWEEN @FromTimestamp AND @to)
你比較了執行計劃嗎? – 2012-02-23 23:41:34
感謝您的建議。它看起來像是所有的XML ..沒有什麼,但其他地方0%。我也注意到sql server express機器沒有超過25%cpu ... – 2012-02-23 23:51:10