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 8161241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:27:27+00:00 2026-06-06T18:27:27+00:00

I have 2 stored procedures ( sp1 and sp2 ) in SQL Server 2005

  • 0

I have 2 stored procedures (sp1 and sp2) in SQL Server 2005 with the same sql script (no diff at all but the name).

When I try to execute sp1 it returns more than 3000 rows as result, in 0-1 secs.
But when I run sp2 it will return those 3000 rows in 10 seconds.

Would like to know is there any tool/command/anything which can set a specific stored procedure to optimize well?

Thanks.

  • 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-06-06T18:27:29+00:00Added an answer on June 6, 2026 at 6:27 pm

    SQL Server saves “plans” of how to execute code.

    If a stored procedure is run against a small subset of data it will optimize for a small dataset. The opposite is true for a large dataset.

    Theres a nice OPTIMIZE FOR feature in 2008 but in 2005 you are stuck with WITH RECOMPILE. This means it will be recompiled each time it is run, which, in some cases is most optimal!

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

Sidebar

Related Questions

This is two part question: I have two stored procedures: sp1 & sp2. If
Using Entity Framework 4 with stored procedures and SQL Server 2008 SP1... When running
I have a database in MS SQL Server 2008, I have Stored Procedures. One
We have two stored procedures in Microsoft SQL Server that return data that is
I have a stored procedure in SQL Server with try catch. What I want
I have stored procedures in SQL Server T-SQL that are called from .NET within
I have 10 stored procedures as follows: SP1,SP2,.....,SP10 These stored procedures do some stuff.
I have three stored procedures Sp1 , Sp2 and Sp3 . The first one
In a SQL Server database I need to find all stored procedures and views
I have two stored procedures I wish to use in my stored procedure, but

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.