Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Query performance

Query performance

Scheduled Pinned Locked Moved Database
databaseperformancehelpquestion
8 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SatyaKeerthi15
    wrote on last edited by
    #1

    I have a stored procedure with two params in sql2005. If I excute the stored procedure it takes 2 min but i copied the same query in new window, declare variables and run the query it takes 1sec. What is the problem.

    L D S B 4 Replies Last reply
    0
    • S SatyaKeerthi15

      I have a stored procedure with two params in sql2005. If I excute the stored procedure it takes 2 min but i copied the same query in new window, declare variables and run the query it takes 1sec. What is the problem.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Can you post the query?

      I are Troll :suss:

      1 Reply Last reply
      0
      • S SatyaKeerthi15

        I have a stored procedure with two params in sql2005. If I excute the stored procedure it takes 2 min but i copied the same query in new window, declare variables and run the query it takes 1sec. What is the problem.

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        Is it having dynamic queries? Without watching the code, it is quite difficult to find the problem. Can you post relevant code? (Please do not dump everything. Just provide relevant code and use code block link.) :)

        1 Reply Last reply
        0
        • S SatyaKeerthi15

          I have a stored procedure with two params in sql2005. If I excute the stored procedure it takes 2 min but i copied the same query in new window, declare variables and run the query it takes 1sec. What is the problem.

          S Offline
          S Offline
          scottgp
          wrote on last edited by
          #4

          Whenever I hear of a query taking longer in a stored procedure, I believe it usually ends up being due to something called "parameter sniffing" - see http://blogs.msdn.com/b/queryoptteam/archive/2006/03/31/565991.aspx[^]. Scott

          J M P 3 Replies Last reply
          0
          • S scottgp

            Whenever I hear of a query taking longer in a stored procedure, I believe it usually ends up being due to something called "parameter sniffing" - see http://blogs.msdn.com/b/queryoptteam/archive/2006/03/31/565991.aspx[^]. Scott

            J Offline
            J Offline
            Jorgen Andersson
            wrote on last edited by
            #5

            Good info!

            "When did ignorance become a point of view" - Dilbert

            1 Reply Last reply
            0
            • S scottgp

              Whenever I hear of a query taking longer in a stored procedure, I believe it usually ends up being due to something called "parameter sniffing" - see http://blogs.msdn.com/b/queryoptteam/archive/2006/03/31/565991.aspx[^]. Scott

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Thank you, I've been looking for that article for ages, it (or a similar article) was posted some time ago as a similar response and I didn't grab it then.

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • S scottgp

                Whenever I hear of a query taking longer in a stored procedure, I believe it usually ends up being due to something called "parameter sniffing" - see http://blogs.msdn.com/b/queryoptteam/archive/2006/03/31/565991.aspx[^]. Scott

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                A friend of mine just informed me about that this week. :thumbsup:

                1 Reply Last reply
                0
                • S SatyaKeerthi15

                  I have a stored procedure with two params in sql2005. If I excute the stored procedure it takes 2 min but i copied the same query in new window, declare variables and run the query it takes 1sec. What is the problem.

                  B Offline
                  B Offline
                  Bernhard Hiller
                  wrote on last edited by
                  #8

                  When you encounter such a performance difference, does it then matter, which one was executed first? Or in other words: is the stored procedure faster after you run the normal query? SQL Server can cache execution plans and results, maybe that's the issue here.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups