The follow info comes from Oracle documet
To minimize the time it takes for an application to reserve a database connection from a data source and to eliminate contention between threads for a database connection, you can add the
Pinned-To-Threadproperty in the connection Properties list for the data source, and set its value to
Pinned-To-Threadis enabled, WebLogic Server pins a database connection from the data source to an execution thread the first time an application uses the thread to reserve a connection. When the application finishes using the connection and calls
connection.close(), which otherwise returns the connection to the data source, WebLogic Server keeps the connection with the execute thread and does not return it to the data source. When an application subsequently requests a connection using the same execute thread, WebLogic Server provides the connection already reserved by the thread. There is no locking contention on the data source that occurs when multiple threads attempt to reserve a connection at the same time and there is no contention for threads that attempt to reserve the same connection from a limited number of database connections.
Note:In this release, the Pinned-To-Thread feature does not work with multi data sources, Oracle RAC, and IdentityPool. These features rely on the ability to return a connection to the connection pool and reacquire it if there is a connection failure or connection identity does not match.
Changes to Connection Pool Administration Operations When PinnedToThread is Enabled
Because the nature of connection pooling behavior is changed when
PinnedToThreadis enabled, some connection pool attributes or features behave differently or are disabled to suit the behavior change:
- Maximum Capacity is ignored. The number of connections in a connection pool equals the greater of either the initial capacity or the number of connections reserved from the connection pool.
- Shrinking does not apply to connection pools with
PinnedToThreadenabled because connections are never returned to the connection pool. Effectively, they are always reserved.
- When you Reset a connection pool, the reset connections from the connection pool are marked as Test Needed. The next time each connection is reserved, WebLogic Server tests the connection and recreates it if necessary. Connections are not tested synchronously when you reset the connection pool. This feature requires that Test Connections on Reserve is enabled and a Test Table Name or query is specified.
Additional Database Resource Costs When PinnedToThread is Enabled
WhenAlso note that connections are never returned to the connection pool, which means that the connection pool can never shrink to reduce the number of connections and associated resources in use. You can minimize this cost by setting an additional driver parameter
PinnedToThreadis enabled, the maximum capacity of the connection pool (maximum number of database connections created in the connection pool) becomes the number of execute threads used to request a connection multiplied by the number of concurrent connections each thread reserves. This may exceed the Maximum Capacity specified for the connection pool. You may need to consider this larger number of connections in your system design and ensure that your database allows for additional associated resources, such as open cursors.
true, only the first connection requested is pinned to the thread. Any additional connections required by the thread are taken from and returned to the connection pool as needed. Set
Propertiesattribute, for example:
If your system can handle the additional resource requirements, Oracle recommends that you use the
PinnedToThreadoption to increase performance.
If your system cannot handle the additional resource requirements or if you see database resource errors after enabling
PinnedToThread, Oracle recommendsnot using
PinnedToThread would definitely improve the performance. Its main is to workaround threading limitations when you use JDBC Type 2 XA drivers.