Solved

SQL Server view query slow until refreshed

Posted on 2013-01-23
1
290 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

11 Experts available now in Live!

Get 1:1 Help Now