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. Connection Resources

Connection Resources

Scheduled Pinned Locked Moved Database
databasesql-serversysadminperformancequestion
2 Posts 2 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.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    The main application where I work creates and then destroys a Connection object for every stored procedure that it calls. (SQL Server 2012) Is this unnecessarily wasteful to the point where it might speed things up to reuse open connections? Or do you think it doesn't make much of a difference?

    The difficult we do right away... ...the impossible takes slightly longer.

    Richard DeemingR 1 Reply Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      The main application where I work creates and then destroys a Connection object for every stored procedure that it calls. (SQL Server 2012) Is this unnecessarily wasteful to the point where it might speed things up to reuse open connections? Or do you think it doesn't make much of a difference?

      The difficult we do right away... ...the impossible takes slightly longer.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      It's the recommended approach - create the connection as close as possible to where it's needed, and wrap it in a "using" block to make sure it's disposed of as soon as you're done with it. Connection pooling will automatically keep a pool of the low-level connections alive to speed up reconnecting. So long as you're using the same connection string each time, and you dispose of the connection when you're done with it, you shouldn't have any performance issues caused by connecting to SQL. SQL Server Connection Pooling - ADO.NET | Microsoft Docs[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      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