Solved

SQL Server view query slow until refreshed

Posted on 2013-01-23
1
292 Views
Last Modified: 2013-01-27
I have a view that starts performing slowly when queried via a C# program using LINQ to SQL.  The equivalent query executed in management studio performs fine.  By equivalent I mean that the SQL code that is created by LINQ to SQL is pasted into management studio and executed.

After I run sp_refreshview then the LINQ to SQL C# program performs as well as running the query in management studio.  There have not been any changes to the schema during this period.

Any ideas?
0
Comment
Question by:codebozo
1 Comment
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 500 total points
ID: 38812485
I suggest adding "OPTION (RECOMPILE)" to any SELECTs from this view and seeing if that solves the problem.

Sounds like you have the equivalent of the "parameter sniffing" issue for stored procs.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now