HI,
I am using simple query thats two views and one table are
referred in the table.In one view I am having multiple rows so I am using distinct.my query almost takes 8mts to complete.
Below is my query.Pl somebody help me to modify the query
for efficiency.I am using sql2005
SELECT vsm.secid,vsm.PrimarySecId,vsm.PrimarySecType,vsm.SecName,vsm.LongDesc,vsm.Coupon,
vsm.Maturity, vsm.SecClass,vsm.PerfClass,vsm.SecType, vsm.Moody, vsm.SP,vsm.CountryofIssue,
vsm.Country, vsm.Currency,sp.Price,
case
When vsm.MgrName is Null or rtrim(vsm.MgrName) = '' THEN
'UNASSIGNED'
ELSE
vsm.MgrName
End MgrName
from vwsecmaster vsm
inner join
(Select distinct security_id,AsOfDt from vwPositions where AsOfDt ='2007-01-23')pos
on Pos.Security_id = vsm.SecID
inner join
(select secid,price from secprice where pricedate='2007-01-23')sp
on sp.secid = vsm.secid
--and sp.PriceDate = '2007-01-23' and
where vsm.PerfClass = 'DEBT'
I am using simple query thats two views and one table are
referred in the table.In one view I am having multiple rows so I am using distinct.my query almost takes 8mts to complete.
Below is my query.Pl somebody help me to modify the query
for efficiency.I am using sql2005
SELECT vsm.secid,vsm.PrimarySecId,vsm.PrimarySecType,vsm.SecName,vsm.LongDesc,vsm.Coupon,
vsm.Maturity, vsm.SecClass,vsm.PerfClass,vsm.SecType, vsm.Moody, vsm.SP,vsm.CountryofIssue,
vsm.Country, vsm.Currency,sp.Price,
case
When vsm.MgrName is Null or rtrim(vsm.MgrName) = '' THEN
'UNASSIGNED'
ELSE
vsm.MgrName
End MgrName
from vwsecmaster vsm
inner join
(Select distinct security_id,AsOfDt from vwPositions where AsOfDt ='2007-01-23')pos
on Pos.Security_id = vsm.SecID
inner join
(select secid,price from secprice where pricedate='2007-01-23')sp
on sp.secid = vsm.secid
--and sp.PriceDate = '2007-01-23' and
where vsm.PerfClass = 'DEBT'