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 on view doesn't work with where clause

Author  Topic 

notmyrealname

98 Posts

Posted - 2014-06-04 : 13:00:54
Hi,

I have a view that executes fine. It returns about a million records and executes in a couple seconds. The problem I am having is that if I query the view with a filter it executes very slowly. About a row per second - so it would take forever to complete.

This works fine...
SELECT     *
FROM vw_AssemblyInquiry

But this does not...
SELECT     *
FROM vw_AssemblyInquiry
WHERE (Project = N'12-282')

In addition, if I add the filter directly to the view query then it will work fine. I just won't work if I append a filter to a SELECT against the view.

I hope this is clear enough. Does any understand what is happening?

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-04 : 13:01:48
Do you have an index on Project? Is it an indexed view?

Show us the execution plan of both queries.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

notmyrealname

98 Posts

Posted - 2014-06-09 : 10:34:42
Sorry for the delay. This issue seemed to have resolved itself. For a couple days it would not work but now everything is working again. I do not manage the server so I don't know if there was something occurring in the background that would have caused this issue. Thanks for your help. I have double checked to ensure all of my indexes are in place.
Go to Top of Page
   

- Advertisement -