SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Training
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
SQL Azure
Developer
General DBA
ASP.NET / ADO.NET
SQL Azure

USEFUL SITES :

ASP.NET Tutorials
Windows and SQL Azure Tutorials
Cloud Hosting Magazine
SharePoint Tutorials
Windows Server Help

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server

More     
 
Latest FAQ's

Add Node to A SQL Server failover Cluster failed with invalid ...
SQL Server Destination remote server error
Setting Up Data And Log Files For SQL Server
Will Check Constraints Improve Database Performance?

More     
   
Latest Software Reviews

dbForge Review
Spotlight on ApexSQL Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Data Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Doc 2008

More     

articles >> performance tuning >> SQL Server Connection Pooling Myths

SQL Server Connection Pooling Myths

By : Shawn Kresal
Nov 03, 2004

Many of us are already familiar with connection pooling and understand to some degree its importance in web and SQL Server programming. We’ve all heard the adage that “connections are expensive” and “pooling is good”. This article will examine the topic in more detail, bringing to light some of the finer points of connection pooling.

Why is connection pooling so beneficial? Creating a connection is expensive; it requires your application to connect to the database server, authenticate, and return a valid connection. Drawing from the pool eliminates this overhead. With web applications, proper pooling is absolutely critical to performance because IIS closes all of a page’s database connections after a page is processed. With hundreds, thousands, or millions of page requests, each wanting a new database connection, were it not for pooling, our site’s performance would quickly become unacceptable.

Take this quick test to see how well you understand connection pooling with IIS and SQL Server. Keep track of which questions you answer true and, if you’re impatient like me, skip to the end of this article, otherwise follow along as we dissect each answer.

  1. True or False: Changing the connection string, even slightly, will force a new connection.

     
  2. True or False: Setting a connection to Nothing is important for proper pooling.

  3. True or False: Changing the CursorLocation (adUseClient to adUseServer for example) or Mode (adModeRead, adModeShareDenyRead, etc.) of a pooled connection may cause problems when it is returned to the pool.

     
  4. True or False: Modifying the ConnectionTimeout will cause the pooled connection to remember this new value and could introduce problems when it goes back into the connection pool.

     
  5. True or False: Opening multiple recordsets on the same connection object will insure you take a connection from the pool.
 

Establishing Our Baseline

Before we can accurately assess what our connection pool is doing, we need to look at it under the ideal scenario. Let’s create an ASP page that opens 1000 connections as quickly as possible. All connections will use the same connection string and perform only a simple SELECT statement. We’ll use the pubs database with a login name of “pubsLogin”.

 

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Option Explicit

 

Const strConnectString = "Provider=sqloledb;User ID=pubsLogin; pwd=pubsPassword; Data Source=YourServerName; Initial Catalog=pubs"

Const strSQL = "SELECT * FROM Authors WHERE au_lname='This is SQL Statement 1'"

 

Dim cnPubs ' As New ADODB.Connection

Dim i

 

For i = 1 To 1000

    Response.Write "Iteration " & i & “<br>”

    Set cnPubs = Server.CreateObject("ADODB.Connection")

    cnPubs.ConnectionString = strConnectString

    cnPubs.Open

 

    cnPubs.Execute strSQL

    Response.Write "&nbsp;”  ‘ our simple delay tactic

 

    cnPubs.Close

    Set cnPubs = Nothing

    Response.Flush

Next '

Response.Write “<p>Done”

</script>


    Next Page>>    








C# Help and Tutorials | PHP MySQL Tutorial | Sharepoint Tutorial | Azure Tutorial | Cloud Hosting Magazine | ASP.NET Tutorials | Windows Server Help | Windows Phone Pro | Silverlight Ace | Visual Studio Tutorials | Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | SQL Server Training Videos | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 2010 Jude O'Kelly. All rights reserved