ADO Connection Pool Effect

Source: Internet
Author: User
Tags connection pooling

Enable connection pooling            string constr = "Data sourse=zxtiger; Initial catalog=itcastcn;integrated security=true ";            Stopwatch watch = new Stopwatch ();            Watch. Start ();            for (int i = 0; i < i++)            {                using (SqlConnection con = new SqlConnection (constr))                {                    con. Open ();                    Con. Close ();                }            }            Watch. Stop ();            Console.WriteLine (watch. Elapsed);            Console.readkey ();
Once connection pooling is enabled, only one connection operation is performed
Disable connection pooling            string constr = "Data sourse=zxtiger; Initial catalog=itcastcn;integrated security=true; Pooling=false ";            Stopwatch watch = new Stopwatch ();            Watch. Start ();            for (int i = 0; i < i++)            {                using (SqlConnection con = new SqlConnection (constr))                {                    con. Open ();                    Con. Close ();                }            }            Watch. Stop ();            Console.WriteLine (watch. Elapsed);            Console.readkey ();

Connection pooling is turned on by default when the connection pool is disabled

00:00:00.1383385
00:00:03.9974913

Before and after the difference 29 is

The benefit of connection pooling is that you keep the connection object, preventing you from instantiating a connection object the next time.

Because each normal connection database performs at least 3 operations (1. Log on to database server 2. Perform operation 3. Log off the user), so it is time-consuming to request a connection to the database server via Connection "ADO-enabled connection pooling by default"

ADO Connection Pool Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.