VistaDB 6
VistaDB / Developer's Guide / How To Perform Common Tasks / How To - Use Connection Pooling
In This Topic
    How To - Use Connection Pooling
    In This Topic

    Connection pooling enables your .NET application to recycle a connection a pool of connections that have been previously closed. Once a connection with a particular connection string has been created it is placed in a pool during the Close() operator and an application can then reuse that connection without the expense of rebuilding the entire object. When the application requests a connection an existing object is returned from the set of pooled connections.  When the object is closed again it will be added back to the pool for reuse.

    Connection pooling only works when you use the exact same connection string each time. If any of the settings in the connection string are different a new connection will be opened.

    This can have a substantial, positive impact on the performance of your application. When a new connection is built VistaDB must open the database, validate the headers of the file, check to make sure the version of the database is the same as the engine, etc. In other words a lot of housekeeping happens when you first build a connection.

    Connection pooling may be enabled by setting the "Pooling=true" keypair in your connection string. The default minimum pool size is 5, and the maximum is 50.

    Do not use connection pooling in any Exclusive mode: Since these require a single connection you will want to explicitly control that connection lifecycle with open and close and not have it go back to the pool to avoid hard-to-debug contention issues.

    In general connections should be treated either as a global that you lock and manage yourself, or opened with using statements and torn down as quickly as possible.

    Connection pool settings may be set in the connection string, or through the properties of the VistaDBConnectionStringBuilder. See this topic for more information.

    See Also