Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6734233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:51:52+00:00 2026-05-26T10:51:52+00:00

When executed from Management Studio the stored procedure finishes in <0.1s, but when executed

  • 0

When executed from Management Studio the stored procedure finishes in <0.1s, but when executed via EF it takes over 2s.

Below is profiler output:

Profiler output

A bit ironic since the reason for creating the SP was to improve performance on an EF query that took around 1.2s.

UPDATE
For whatever it is worth, the SP result is mapped to an EF complex type. I call without any hocus pocus:

var menuTags = db.GetMenuTags(2, "en-US");

The SQL generated by EF is:

exec [dbo].[GetMenuTags] @CustTypeId=2,@LanguageId='en-US                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           '

The only difference is a bunch of blank spaces EF adds to the end of @LanguageId, but they don’t affect the performance. I have tried the exact same SQL in MSSMS and it works just as well as without the blank spaces.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:51:53+00:00Added an answer on May 26, 2026 at 10:51 am

    SPs executed via EF always return all rows, could that be the delay.

    Maybe posting your SP and the original EF generated SQL will help

    Edited to add what appears to be the solution

    Another thought (from days gone by) Parameter sniffing was oft the culprit for a slow SP which had been run by a developer with bad parameters and then set up a crappy execution plan. Adding the WITH RECOMPILE option to get a new plan based on decent parameters would resolve this problem mostly. Another cheat was to assign the passed in parameters into local sql variables (local to the SP) and only use local variables in the query.

    Now you have the SP with a decent execution plan you should be able to remove the ‘WITH RECOMPILE’ and it’ll still work. Parameter Sniffing problems are rare I would say.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a stored procedure that takes 15 min when executed from Management Studio.
I have a stored procedure that executes much faster from Sql Server Management Studio
In SqlServer Management Studio when I execute stored procedure and it throws exception it
I have created a stored procedure in SQL Server, which runs immediately from Management
In MS SQL Server Management Studio 2005, running this code EXEC('SELECT * FROM employees
Hey all this is the first time i am calling a stored procedure via
I have stored procedure that insanely times out every single time it's called from
I'm trying to call a stored procedure (on a SQL 2005 server) from C#,
I am having difficulty executing a MS SQL Server stored procedure from Java/jsp. I
I executed the following Query in SQL Server Management studio 2005 and I did

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.