Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 query help

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-12-09 : 23:38:58
Dear All,

I have this query


SELECT Address.ID, Address.Postcode, Address.CityTown, Address.SuburbDistrict, Address.StateProvince, Address.Country_ID, Address.AddressType_ID, Address.Postcode_ID
FROM Address
LEFT JOIN
s2_usn ON (Address.ID=s2_usn.table_id and s2_usn.tablename='Address')

WHERE (Address.ID IN (SELECT Address_ID FROM Account LEFT JOIN s2_usn on (Account.ID=s2_usn.table_id and s2_usn.tablename='Account')
WHERE ((Country_ID = 63) AND IsActive = 1 AND s2_usn.ID IS NULL)))
OR (Address.ID IN (SELECT Account_Address.Address_ID FROM Account_Address INNER JOIN Account ON Account_Address.Account_ID = Account.ID


LEFT JOIN s2_usn on (Account.ID=s2_usn.table_id and s2_usn.tablename='Account')
WHERE ((Account.Country_ID = 63) AND Account.IsActive = 1 AND s2_usn.ID IS NULL)))
AND (Country_ID = 63) AND s2_usn.ID IS NULL


It was running earlier within 1 to 2 minutes now its taking more than 8 minutes to run because of this my application is getting timed out.

As this is vendor application i can't change the T-SQL code is it possible to do something to increase performance.

In the query plan it shows Index spool(eager spool) with 66% cost and table spool(laze spool) 23% cost.

How to minimize this.

Help me to get resolution for this.

Thanks,
Gangadhar

chadmat
The Chadinator

1974 Posts

Posted - 2010-12-09 : 23:56:20
Have you tried updating stats?

-Chad
Go to Top of Page

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-12-10 : 00:12:40
Do i need to update statistics for only these 2 tables or for the whole database ?

If anything other than that do i need to SEE ?
Go to Top of Page
   

- Advertisement -