Statement Caching Connection String Attributes The following connection string attributes control the behavior of the ODP.NET statement caching feature:
Statement Cache Size
This attribute enables or disables ODP.NET statement caching. By default, this attribute is set to 0 (disabled). If it is set to a value greater than 0, ODP.NET statement caching is enabled and the value specifies the maximum number of statements that can be cached for a connection. Once a connection has cached up to the specified maximum cache size, the cursor least recently used is freed to make room to cache the newly created cursor.
Statement Cache Purge
This attribute provides a way for connections to purge all statements that are cached when a connection is closed or placed back into the connection pool. By default, this attribute is set to false, which means that cursors are not freed when connections are placed back into the pool.
Enabling Statement Caching through the Registry To enable statement caching by default for all ODP.NET applications running in a system, without changing the application, set the registry key of HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEID\ODP.NET\StatementCacheSize to a value greater than 0. (ID is the appropriate Oracle Home ID.) This value specifies the number of cursors that are to be cached on the server. By default, it is set to 0.
Statement Caching Methods and Properties The following property and method are relevant only when statement caching is enabled:
OracleCommand.AddToStatementCache property
If statement caching is enabled, having this property set to true (default) adds statements to the cache when they are executed. If statement caching is disabled or if this property is set to false, the executed statement is not cached.
OracleConnection.PurgeStatementCache method
This method purges all the cached statements by closing all open cursors on the database that are associated with the particular connection. Note that statement caching remains enabled after this call.
Connections and Statement Caching Statement caching is managed separately for each connection. Therefore, executing the same statement on different connections requires parsing once for each connection and caching a separate cursor for each connection.
Pooling and Statement Caching Pooling and statement caching can be used in conjunction. If connection pooling is enabled and the Statement Cache Purge attribute is set to false,