简体   繁体   中英

ODP.NET connection pooling off for single connection?

Using Oracle's ODP.NET library, the application I'm working on needs to perform two different types of queries, where one type can be relatively slow, but the other must be fast. The current application code I've inherited disables connection pooling entirely and keeps a specific connection object open for the "fast" query, which is great for that purpose because we can switch to another open connection if the first call has taken more than X milliseconds, alerting the user that the data didn't return fast enough if the second call doesn't come back quickly enough.

At the same time, having changed the connection string to enable pooling, the general queries we run come back much faster, so it'd be nice to use pooling for those queries.

Is there a way I can enable pooling for most purposes, but disable it for specific connection objects? Or would it be easier (since we've already got code basically "pooling" two connections for the critical query) to just extend the existing code to rotate through a small collection of connection objects for the general queries, and keep two other connections separate for the more critical query?

In the article @Mino linked to here , it states:

If any one of the connection string parameters is modified, ODP.NET will create a new connection pool for your application when the next connection is requested.

Extending and clarifying that statement based on the information from Visual Studio's debugger and the disassembly tool JustDecompile, I'm confident that:

  • The current ODP.NET connector creates a new connection pool any time anything in the connection string changes, extending even to addition or removal of whitespace in unimportant sections of the string
  • Any connection made with pooling turned off is created without use of a connection pool even if a pool for that server exists.
  • And, any new connections opened that use a connection string that already has a connection pool will continue to use the old pool.

Oracle's connection pooling really is smart enough to do what I wanted. All of this investigated with Oracle.ManagedDataAccess.dll v4.121.1.0 as part of the ODAC 12.1.0.1.0 with Oracle Developer Tools for Visual Studio package from Oracle.com.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM