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

  • Home
  • SEARCH
  • 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 6058713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:37:46+00:00 2026-05-23T08:37:46+00:00

I have a stored procedure (sproc) called resetflags. It takes an int parameter. Another

  • 0

I have a stored procedure (sproc) called resetflags. It takes an int parameter. Another sproc editInspection calls it. Sproc editInspection is like this:

  1. update a single row on a table (duration < 0.00 sec)
  2. execute another sproc (duration < 0.00 sec)
  3. execute sproc resetFlags (duration ~ 16 secs!!!)
  4. select single row (duration < 0.00 sec)

If I comment out line 3 and run the sproc it finishes within 0 secs.
If I run line 3 by itself it finishes in 1 sec.
If I comment out line 1 and 2 the sproc takes 16 secs.

The database does not contain any trigger (I am a trigger-less happy person). There is no user-assigned transactions anywhere. I am using SQL 2008 Dev edition.

I have just timed it and some other test script using the profiler. Here are my findings:

Case 1: Ran the script to execute sproc editInspection with parameters. Took 16000 ms.

Case 2: Created a test script. Changed to code for sproc editInspection so that all params are local variables. Assigned values to those local vars, and then executed the code. Took around 16000 ms.

CASE 3: Commented out ‘exec resetflags’ from sproc editInspection and then ran something like the following:

execute editInspection param1,…param n
execute resetflags param1

So sproc resetflag is now running outside the sproc editInspection. This took 600-700 ms to finish.

Case 4: Took the test script from case 2. Commented out all except one variable declaraion and assignment. Commeneted out all other statements except execution of resetFlags. So the script is basically

declare param1 int
/*
commented out declare stmts
/
SET param1 = some value
/

commented out SET stmts
commented out SELECTs, UPDATE and EXECUTE
*/
execute resetFlags param1

This one took ~ 16000 ms.

Case 5: Copied the code from case 4 and pasted it on a new query window. Executed it, and it took around 700 ms! This is the strange part.

Case 6: Executed sproc resetFlags with value for the parameter. Took around 600 ms.

Any clue on what to look for will be much appreciated. I know I have not posted the code/table defintions and sample data. The defintions and code are quite large, and I am being lazy as well.

  • 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-23T08:37:46+00:00Added an answer on May 23, 2026 at 8:37 am

    I would strongly suggest parameter sniffing as the culprit.

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

Sidebar

Related Questions

I have a Stored procedure which schedules a job. This Job takes a lot
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I have a deprecated stored procedure which should no longer be called from code,
I have stored procedure that returns results sorted dynamically. The parent folder (this is
I have seen various rules for naming stored procedures. Some people prefix the sproc
I have stored procedure: ALTER PROCEDURE [dbo].[k_ShoppingCart_DELETE] @cartGUID nvarchar AS DELETE FROM [dbo].[k_ShoppingCart] WHERE
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have a stored procedure in SQL 2005. The Stored Procedure is actually creating
I have a stored procedure that consists of a single select query used to
I have a stored procedure with the following header: FUNCTION SaveShipment (p_user_id IN INTEGER,

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.