SQL Server, connection pools vs static connection for special cases

I sort of know the answer to this, but cannot really grasp the underlying concept. I know you are always instructed to use connection pooling now. But imagine this scenario.

I need to read data from one database, and one table, multiple times.

  • How to summarise data according to the AcctName in Sql query
  • select get results then delete
  • Local database without sql server
  • SQL Table valued function
  • Is a simple ASP.NET site using SQL Server known as 2-Tier Architecture?
  • Case in Select Statement
  • Connection pooling is going to inject microseconds of overhead, but why not eliminate that by using a single connection for everything and locking around that?

    Since it is one database, with one table. Isn’t it pretty unlikely that we will be able to get any performance boost from multithreaded connection pools?

    Just hoping for some clarity here. And maybe some simple resources which would explain WHY, connection pooling ALWAYS is better.

    Thanks. I know this is not the greatest question, and I appreciate your time. I am specifically in the .net environment, but this is a basic concept across programming correct?

  • Php SQL Server table value parameter
  • Why can't I access my database on a webpage?
  • Copyable Coldfusion SQL Exception
  • What’s the best way to capitalise the first letter of each word in a string in SQL Server
  • Need help with some stored procedure
  • Update with inner join to same table optimizations
  • One Solution collect form web for “SQL Server, connection pools vs static connection for special cases”

    1. With one global connection you need to be prepared to handle spurious connection failues. Those can always happen (network hiccup, …).
    2. You absolutely do get concurrency when using multiple concurrent statements against a single table. SQL Server does not usually lock tables exclusively (exceedingly rare).
    3. You will forget to use the synchronization protocol somewhere (lock everywhere). You will get it wrong eventually and have to fight races.
    4. If you have a slow runaway query that would block the entire app. It will appear “hung” to browsers.
    5. You serialize all HTTP requests on the global lock. You only use one CPU. You won’t scale at all. Your app will not handle burst well.

    Having a single global connection is really a bad idea. Why not just use pooling? That saves you the development work of using synchronization. It is even less work.

    Of course, pooling is not always better. You can construct pathological cases where it isn’t. I never encountered a case where I needed to keep a connection open for longer than the current HTTP request, though.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.