Remember That Those Connections are Precious


The most common error I see in badly scalable database code is reckless use of the connection object. For all multi-user database programming (which accounts for most of the work these days), database connections are a limited resource. Don't let it be your code that is hanging on to his connection way after you are finished with it. I am *not* saying that all work can be done disconnected. I am simply asking you to keep in mind that Connections are precious things. Try to do these two things:

  • Open Connections as Late as possible.
  • Close Connections as Early as possible.

Most people concentrate on closing their connections early. This is good and well known. But I have seen more than my share of code (including mine!) that opened database connections too early.




Application Name WilderBlog Environment Name Production
Application Ver 2.0.0.0 Runtime Framework .NETCoreApp,Version=v2.0
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.00001.0
Operating System Microsoft Windows 6.2.9200 Runtime Arch X86