PC Review


Reply
Thread Tools Rating: Thread Rating: 3 votes, 1.00 average.

ADO.NET RPC Slower than Management Studio

 
 
Dereck
Guest
Posts: n/a
 
      16th Apr 2009
I have an ADO.NET Entity Framework generated query which seemed a bit
slow, so I ran SQL Profiler and confirmed that the query was taking
12-13 seconds for each execution. In the profiler the event is an
RPC. If I take the command text from the profiler and run it in
Management Studio, the execution takes 1 second (about 500
milliseconds in profiler). The query never changes, and I have run it
repeatedly hundreds of times with the same disturbing results. When I
run it from Management Studio I noticed it does not come across as an
RPC, but a normal TSQL batch. Any ideas why the RPC takes so much
longer?

Here is an outline of what the query looks like:


exec sp_executesql N'SELECT TOP (1)
[Project1].[C1] AS [C1],
.....
FROM ( SELECT
[Filter1].[AcctID] AS [AcctID],
....
1 AS [C1]
FROM (SELECT [Extent1].[AcctID] AS [AcctID], ....
FROM [dbo].[Account] AS [Extent1]
LEFT OUTER JOIN [dbo].[AccountStatus] AS [Extent2] ON [Extent1].
[AcctStatusID] = [Extent2].[AcctStatusID]
WHERE .... ) AS [Filter1]
INNER JOIN [dbo].[Client] AS [Extent3] ON [Filter1].[ClientID] =
[Extent3].[ClientID]
WHERE (.... = @AccountStatus) AND (.... = @ClientId)
) AS [Project1]
ORDER BY [Project1]..... DESC',N'@AccountStatus int,@ClientId
int',@AccountStatus=1,@ClientId=1
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      16th Apr 2009

Google "Sql Server" "Parameter Sniffing". <<To at the least familiarize
yourself with the issue......

I know how to fix it with traditional usp calls.

I don't know what the ADO.NET Entity Framework fixes might be.

If you find this is the issue and a workaround........then post it here !





"Dereck" <(E-Mail Removed)> wrote in message
news:c73ec655-00cd-4ff0-ba98-(E-Mail Removed)...
>I have an ADO.NET Entity Framework generated query which seemed a bit
> slow, so I ran SQL Profiler and confirmed that the query was taking
> 12-13 seconds for each execution. In the profiler the event is an
> RPC. If I take the command text from the profiler and run it in
> Management Studio, the execution takes 1 second (about 500
> milliseconds in profiler). The query never changes, and I have run it
> repeatedly hundreds of times with the same disturbing results. When I
> run it from Management Studio I noticed it does not come across as an
> RPC, but a normal TSQL batch. Any ideas why the RPC takes so much
> longer?
>
> Here is an outline of what the query looks like:
>
>
> exec sp_executesql N'SELECT TOP (1)
> [Project1].[C1] AS [C1],
> ....
> FROM ( SELECT
> [Filter1].[AcctID] AS [AcctID],
> ....
> 1 AS [C1]
> FROM (SELECT [Extent1].[AcctID] AS [AcctID], ....
> FROM [dbo].[Account] AS [Extent1]
> LEFT OUTER JOIN [dbo].[AccountStatus] AS [Extent2] ON [Extent1].
> [AcctStatusID] = [Extent2].[AcctStatusID]
> WHERE .... ) AS [Filter1]
> INNER JOIN [dbo].[Client] AS [Extent3] ON [Filter1].[ClientID] =
> [Extent3].[ClientID]
> WHERE (.... = @AccountStatus) AND (.... = @ClientId)
> ) AS [Project1]
> ORDER BY [Project1]..... DESC',N'@AccountStatus int,@ClientId
> int',@AccountStatus=1,@ClientId=1



 
Reply With Quote
 
Travis75
Guest
Posts: n/a
 
      24th Apr 2009
You may want to look at the ARITHABORT settings in SQL management studio.
ADO.NET and SQL MS have different default settings for this (cannot remember
which is which), but the differences result in different query plans. Try
running the query in SQL MS with the setting ON and then OFF and see if the
timings change. I've seen this introduce performance issues between the
different executions.

"Dereck" wrote:

> I have an ADO.NET Entity Framework generated query which seemed a bit
> slow, so I ran SQL Profiler and confirmed that the query was taking
> 12-13 seconds for each execution. In the profiler the event is an
> RPC. If I take the command text from the profiler and run it in
> Management Studio, the execution takes 1 second (about 500
> milliseconds in profiler). The query never changes, and I have run it
> repeatedly hundreds of times with the same disturbing results. When I
> run it from Management Studio I noticed it does not come across as an
> RPC, but a normal TSQL batch. Any ideas why the RPC takes so much
> longer?
>
> Here is an outline of what the query looks like:
>
>
> exec sp_executesql N'SELECT TOP (1)
> [Project1].[C1] AS [C1],
> .....
> FROM ( SELECT
> [Filter1].[AcctID] AS [AcctID],
> ....
> 1 AS [C1]
> FROM (SELECT [Extent1].[AcctID] AS [AcctID], ....
> FROM [dbo].[Account] AS [Extent1]
> LEFT OUTER JOIN [dbo].[AccountStatus] AS [Extent2] ON [Extent1].
> [AcctStatusID] = [Extent2].[AcctStatusID]
> WHERE .... ) AS [Filter1]
> INNER JOIN [dbo].[Client] AS [Extent3] ON [Filter1].[ClientID] =
> [Extent3].[ClientID]
> WHERE (.... = @AccountStatus) AND (.... = @ClientId)
> ) AS [Project1]
> ORDER BY [Project1]..... DESC',N'@AccountStatus int,@ClientId
> int',@AccountStatus=1,@ClientId=1
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO.NET query execution much slower than SQL Management Studio dustbort Microsoft ADO .NET 5 11th Mar 2008 02:17 PM
ADO.NET query execution much slower than SQL Management Studio dustbort Microsoft ASP .NET 2 23rd Feb 2008 01:16 PM
Visual Studio 2005 much slower after SP1 update eljainc@sbcglobal.net Microsoft Dot NET 1 4th Jan 2007 03:40 AM
Can Visual Studio Be Any Slower? Bob L. Microsoft Dot NET 6 23rd Sep 2004 06:29 AM
exe slower than running in visual studio uncah91 Microsoft VB .NET 1 28th Jul 2004 07:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 AM.