数据库视图加条件后变慢
各位高手:
我的这段SQL语句加了 where 的条件后就变慢了, 半天没有结果, 如果不加条件很快就有结果, 请帮看下, 谢谢
Select * from (Select
P.fchrReceiptID as fchrReceiptID,
P.fchrReceiptTypeNO as fchrReceiptTypeNO,
C.fchrCustomer as fchrCustomer,
C.fchrCustomerName as fchrCustomerName,
P.fchrReceiptTypeName as fchrReceiptTypeName,
P.fdtmDate as fdtmDate,
P.fchrReceiptNO as fchrReceiptNO,
DBO.f_U8DRP_GetReceiptBillAge(P.fchrReceiptID,'2011-06-23','0') as fintBillAge
from vw_U8DRP_QueryPayMentDetail P with (nolock) left Join Customer C On P.fchrCustomerID = C.fchrCustomerID
Left Join Area A On C.fchrAreaID = A.fchrAreaID
/*Where 1=1 And (DBO.f_U8DRP_GetAgeAreaShouldAmout(P.fchrReceiptID, '2011-06-23') > 0)
And (DateAdd(day, -1, P.fdtmDate) < '2011-06-23')
And (P.fchrReceiptTypeNO IN ('C01','B05','A06','A07'))
And (P.fdtmDate >= '2011-06-01')
And (P.fchrDepartmentID IN (Select fchrDataID from dbo.f_U8DRP_GetDataRight('{0e5de020-bd0b-42b2-b84d-eda4e400a48b}' ,'001')) )
And (DBO.f_U8DRP_GetReceiptBillAge(P.fchrReceiptID,'2011-06-23',0) >= 80)*/
) B