SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query on view doesn't work with where clause
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

notmyrealname
Yak Posting Veteran

97 Posts

Posted - 06/04/2014 :  13:00:54  Show Profile  Reply with Quote
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

USA
36674 Posts

Posted - 06/04/2014 :  13:01:48  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
Yak Posting Veteran

97 Posts

Posted - 06/09/2014 :  10:34:42  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000