Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Server view query slow until refreshed

Posted on 2013-01-23
1
Medium Priority
?
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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