我在以下查询上运行 sql 分析器
SELECT bl.Invoice_Number, bl.Date_Invoice, ti.TranNo, bt.Description,
CONVERT(decimal(15,2), bl.Invoice_Amount) AS Invoice_Amount, co.Company_ID, co.Account_Nbr,
isnull(bl.Reference,' ') as Reference, bl.Billing_Log_RecID AS BillingKey
FROM [CONN.domain.NET].cwwebapp.dbo.Billing_Log bl
LEFT JOIN [App].dob.tarInvoice ti
ON bl.Invoice_Number = dbo._fnStripLeadZeros(ti.TranNo)
INNER JOIN [CONN.domain.NET].cwwebapp.dbo.Billing_Type bt
ON bl.Billing_Type_ID = bt.Billing_Type_ID
LEFT JOIN [CONN.domain.NET].cwwebapp.dbo.Company co
ON bl.Company_RecID = co.Company_RecID
WHERE bl.Date_Invoice >= '2009-05-05'
AND ti.TranNo IS NULL
AND bl.Invoice_Amount <> 0
AND bl.Billing_Type_ID <> 'D'
AND bl.Billing_Type_ID <> 'P'
-- AND bl.Billing_Type_ID <> 'M'
Order By bl.Invoice_Number
查询在 [App] 服务器上运行并连接到 [Conn] sql 服务器进行连接,图表告诉我
remote query cost : 62%
customered index scan [App].[dbo].tarInvoice.[PK__... Cost : 34%
此查询需要 2 分钟才能运行。关于如何弄清楚如何更有效地运行的任何想法?我猜它与连接到同一网络上的另一个 sql 服务器有关。
提前致谢。