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
 General SQL Server Forums
 New to SQL Server Programming
 Performance Question

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2010-03-27 : 00:38:09
I have a view called "iViewProperties" which contains other tables and views.

Now when I run
"SELECT * FROM iViewProperties" it runs unders 1 secs on SQL 2005 Server

but when I run it with group e.g
"
SELECT DISTINCT TOP (100) PERCENT COUNT(PropertyID) AS NoOfProperties, BuildingType, BuildingTypeID, PropertyType, CompanyID
FROM dbo.iViewProperties
WHERE (CompanyID = 33)
GROUP BY Online, IsDeleted, BuildingType, BuildingTypeID, PropertyType, CompanyID
HAVING (Online = 1) AND (IsDeleted = 0)

AND PropertyType > 0
"

it takes 9 secs which is unacceptable, I have only 4500 rows in the view.
What can I do to speed it up?

Thanks


If it is that easy, everybody will be doing it

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-27 : 02:24:13
have you checked the execution plan? what does it suggest?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -