11g Client result set caching in OCI

I'm trying out this feature in the 11.1.0.6 release. My understanding of this feature is that when enabled with the appropriate server-side init.ora parameters, a 11g OCI client connecting to the instance will cache SQL results locally in some fixed amount of RAM on the client. The idea is that network roundtrips would simply disappear in this situation.
I'm not sure if it's working--or how to tell if it is. I have a 11g instance running and put the 11g client incl. sqlplus on a separate box, setting up TNS connectivity from client to server. Pretty standard stuff. I can connect fine and run the same query over and over, but I see incrementing execution counts on the database side and network traffic between the client and server so I'm guessing that the client-side caching isn't happening. There doesn't seem to be a ton of clear documentation on this feature so I wanted to see if anyone else has kicked it around.
Bob

I am also facing the same issue (enabling client result set caching). I am using Oracle Database 11g Release 11.2.0.2.0.
I have made the below configuration changes
1. Enabled the client result set cache by setting the server side parameter 'client_result_cache_size' to 10485760 (10 MB)
2. Restarted the oracle instance after setting the above parameter
3. Added a table annotation by executing the statement ALTER TABLE emp RESULT_CACHE (MODE FORCE). I verified that the annotation is applied by query the user table later.
4. Enabled statement caching on the client side i.e. on the JDBC driver.
5. Used prepared statements to execute the query so that statement caching kicks in. From the driver logs I verified that execution of subsequent queries after the first one used the same statement handle.
After executing the select prepared statement query for three times I checked the CLIENT_RESULT_CACHE_STATS$ view. But this view didn't result in any rows.
As part of troubleshooting I even tried adding the /*+ RESULT_CACHE */ hint to the query but the view didn't gave any result.
Also on enabling sql trace I could see from tkprof that every execution of the query increased the number of rows fetched on the server which indicates that the client result set caching in OCI isn't working.
Are there any steps which I have missed?
Thanks in advance.

Similar Messages

  • Client side result set cache

    Hello,
    I try to get the client side result set cache working, but i have no luck :-(
    I'm using Oracle Enterprise Edition 11.2.0.1.0 and as client diver 11.2.0.2.0.
    Executing the query select /*+ result_cache*/ * from p_item via sql plus or toad will generate an nice execution plan with an RESULT CACHE node and the v$result_cache_objects contains some rows.
    After I've check the server side cache works. I want to cache the client side
    My simple Java Application looks like
    private static final String ID = UUID.randomUUID().toString();
    private static final String JDBC_URL = "jdbc:oracle:oci:@server:1521:ORCL";
    private static final String USER = "user";
    private static final String PASSWORD = "password";
    public static void main(String[] args) throws SQLException {
    OracleDataSource ds = new OracleDataSource();
    ds.setImplicitCachingEnabled(true);
    ds.setURL( JDBC_URL );
    ds.setUser( USER );
    ds.setPassword( PASSWORD );
    String sql = "select /*+ result_cache */ /* " + ID + " */ * from p_item d " +
    "where d.i_size = :1";
    for( int i=0; i<100; i++ ) {
    OracleConnection connection = (OracleConnection) ds.getConnection();
    connection.setImplicitCachingEnabled(true);
    connection.setStatementCacheSize(10);
    OraclePreparedStatement stmt = (OraclePreparedStatement) connection.prepareStatement( sql );
    stmt.setLong( 1, 176 );
    ResultSet rs = stmt.executeQuery();
    int count = 0;
    for(; rs.next(); count++ );
    rs.close();
    stmt.close();
    System.out.println( "Execution: " + getExecutions(connection) + " Fetched: " + count );
    connection.close();
    private static int getExecutions( Connection connection ) throws SQLException {
    String sql = "select executions from v$sqlarea where sql_text like ?";
    PreparedStatement stmt = connection.prepareStatement(sql);
    stmt.setString(1, "%" + ID + "%" );
    ResultSet rs = stmt.executeQuery();
    if( rs.next() == false )
    return 0;
    int result = rs.getInt(1);
    if( rs.next() )
    throw new IllegalArgumentException("not unique");
    rs.close();
    stmt.close();
    return result;
    100 times the same query is executed and the statement exection count is incemented every time. I expect just 1 statement execution ( client database roundtrip ) and 99 hits in client result set cache. The view CLIENT_RESULT_CACHE_STATS$ is empty :-(
    I'm using the oracle documentation at http://download.oracle.com/docs/cd/E14072_01/java.112/e10589/instclnt.htm#BABEDHFF and I don't kown why it does't work :-(
    I'm thankful for every tip,
    André Kullmann

    I wanted to post a follow-up to (hopefully) clear up a point of potential confusion. That is, with the OCI Client Result Cache, the results are indeed cached on the client in memory managed by OCI.
    As I mentioned in my previous reply, I am not a JDBC (or Java) expert so there is likely a great deal of improvement that can be made to my little test program. However, it is not intended to be exemplary, didactic code - rather, it's hopefully just enough to illustrate that the caching happens on the client (when things are configured correctly, etc).
    My environment for this exercise is Windows 7 64-bit, Java SE 1.6.0_27 32-bit, Oracle Instant Client 11.2.0.2 32-bit, and Oracle Database 11.2.0.2 64-bit.
    Apologies if this is a messy post, but I wanted to make it as close to copy/paste/verify as possible.
    Here's the test code I used:
    import java.sql.ResultSet;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.jdbc.OracleConnection;
    class OCIResultCache
      public static void main(String args []) throws SQLException
        OracleDataSource ods = null;
        OracleConnection conn = null;
        PreparedStatement stmt = null;
        ResultSet rset = null;
        String sql1 = "select /*+ no_result_cache */ first_name, last_name " +
                      "from hr.employees";
        String sql2 = "select /*+ result_cache */ first_name, last_name " +
                      "from hr.employees";
        int fetchSize = 128;
        long start, end;
        try
          ods = new OracleDataSource();
          ods.setURL("jdbc:oracle:oci:@liverpool:1521:V112");
          ods.setUser("orademo");
          ods.setPassword("orademo");
          conn = (OracleConnection) ods.getConnection();
          conn.setImplicitCachingEnabled(true);
          conn.setStatementCacheSize(20);
          stmt = conn.prepareStatement(sql1);
          stmt.setFetchSize(fetchSize);
          start = System.currentTimeMillis();
          for (int i=0; i < 10000; i++)
            rset = stmt.executeQuery();
            while (rset.next())
            if (rset != null) rset.close();
          end = System.currentTimeMillis();
          if (stmt != null) stmt.close();
          System.out.println();
          System.out.println("Execution time [sql1] = " + (end-start) + " ms.");
          stmt = conn.prepareStatement(sql2);
          stmt.setFetchSize(fetchSize);
          start = System.currentTimeMillis();
          for (int i=0; i < 10000; i++)
            rset = stmt.executeQuery();
            while (rset.next())
            if (rset != null) rset.close();
          end = System.currentTimeMillis();
          if (stmt != null) stmt.close();
          System.out.println();
          System.out.println("Execution time [sql2] = " + (end-start) + " ms.");
          System.out.println();
          System.out.print("Enter to continue...");
          System.console().readLine();
        finally
          if (rset != null) rset.close();
          if (stmt != null) stmt.close();
          if (conn != null) conn.close();
    }In order to show that the results are cached on the client and thus server round-trips are avoided, I generated a 10046 level 12 trace from the database for this session. This was done using the following database logon trigger:
    create or replace trigger logon_trigger
    after logon on database
    begin
      if (user = 'ORADEMO') then
        execute immediate
        'alter session set events ''10046 trace name context forever, level 12''';
      end if;
    end;
    /With that in place I then did some environmental setup and executed the test:
    C:\Projects\Test\Java\OCIResultCache>set ORACLE_HOME=C:\Oracle\instantclient_11_2
    C:\Projects\Test\Java\OCIResultCache>set CLASSPATH=.;%ORACLE_HOME%\ojdbc6.jar
    C:\Projects\Test\Java\OCIResultCache>set PATH=%ORACLE_HOME%\;%PATH%
    C:\Projects\Test\Java\OCIResultCache>java OCIResultCache
    Execution time [sql1] = 1654 ms.
    Execution time [sql2] = 686 ms.
    Enter to continue...This is all on my laptop, so results are not stellar in terms of performance; however, you can see that the portion of the test that uses the OCI client result cache did execute in approximately half of the time as the non-cached portion.
    But, the more compelling data is in the resulting trace file which I ran through the tkprof utility to make it nicely formatted and summarized:
    SQL ID: cqx6mdvs7mqud Plan Hash: 2228653197
    select /*+ no_result_cache */ first_name, last_name
    from
    hr.employees
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute  10000      0.10       0.10          0          0          0           0
    Fetch    10001      0.49       0.54          0      10001          0     1070000
    total    20002      0.60       0.65          0      10001          0     1070000
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 94 
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
           107        107        107  INDEX FULL SCAN EMP_NAME_IX (cr=2 pr=0 pw=0 time=21 us cost=1 size=1605 card=107)(object id 75241)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                   10001        0.00          0.00
      SQL*Net message from client                 10001        0.00          1.10
    SQL ID: frzmxy93n71ss Plan Hash: 2228653197
    select /*+ result_cache */ first_name, last_name
    from
    hr.employees
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.01          0         11         22           0
    Fetch        2      0.00       0.00          0          0          0         107
    total        4      0.00       0.01          0         11         22         107
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 94 
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
           107        107        107  RESULT CACHE  0rdkpjr5p74cf0n0cs95ntguh7 (cr=0 pr=0 pw=0 time=12 us)
             0          0          0   INDEX FULL SCAN EMP_NAME_IX (cr=0 pr=0 pw=0 time=0 us cost=1 size=1605 card=107)(object id 75241)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      log file sync                                   1        0.00          0.00
      SQL*Net message from client                     2        1.13          1.13The key differences here are the execute, fetch, and SQL*Net message values. Using the client-side cache, the values drop dramatically due to getting the results from client memory rather than round-trips to the server.
    Of course, corrections, clarifications, etc. welcome and so on...
    Regards,
    Mark

  • Jython or wlst script to enable/disable result set cache at BusinessService

    Hi,
    I am new to creating Jython or wlst script. Can anybody help me out and send me the wlst script to enable/disable businsess service cache in OSB. The script should be called by Proxy Service.
    Thanks

    You cannot change the role name. If you want to use the same account activation scheme as used by the console and the perl script command lines, you must use the exact same names for roles, etc.
    If you don't care about using the console or the command lines to manage roles, you can use any scheme you like, but you cannot mix and match the two schemes.

  • Does OCI client result cache and oracle UCP work together?

    I'm using Oracle 11.2.1.0. I've set up FCF and enabled OCI result cache on server side, so on client side, I'm using UCP for failover.
    this is my datasource configuration:
    <Resource name="jdbc/MyPool"
    auth="Container"
    factory="oracle.ucp.jdbc.PoolDataSourceImpl"
    type="oracle.ucp.jdbc.PoolDataSource"
    connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
    url="jdbc:oracle:oci:@dbhost:1521/myDb"
    user="db_user"
    password="db_password"
    fastConnectionFailoverEnabled="true"
    onsConfiguration=""
    connectionPoolName="dbPool"
    initialPoolSize="5"
    minPoolSize="5"
    maxPoolSize="25"
    connectionWaitTimeout="10000"
    inactiveConnectionTimeout="120000"
    abandonConnectionTimeout="60"
    validateConnectionOnBorrow="true"
    sqlForValidateConnection="select user from dual"
    maxStatements="30"/>
    I've enabled OCI client result cache.
    I use /*+ result_cache */ in my query to take advantage of the result cache.
    so I execute the following scenario:
    i) select /*+ result_cache */ value from myTable where id=1; (this returns a result.)
    ii) update myTable to set a different value for id=1 record;
    iii) run select query again; (this should return a different result. oci result cache gets updated when table changes.)
    if I take out
    "sqlForValidateConnection" and/or "validateConnectionOnBorrow" (i.e. disable sql validation on borrow), the 2nd query after table update doesn't show the latest result. it's still showing the old query result.
    is this a bug? that UCP validation on borrow has an impact on OCI result cache function? this doesn't happen if using dbcp java connection pooling with OCI result cache.

    it turns out I ran the test against an oracle server that doesnt have FCF configured, nor ONS.
    once i switched to a correct oracle cluster, my test passed.

  • Using the Client Result Cache

    Hello everyone,
    I have a question regarding the use of the client result cache but first of all here are the informations about my database:
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0    Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    I have installed the Oracle Client Tools on my clientmachine. It has a tnsnames.ora like this:
    ORCL =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = FEA11-119SRV)(PORT = 1521))
        (CONNECT_DATA =
          (SERVICE_NAME = orcl.local)
    The Client Result Cache is configured in the sqlnet.ora.
    ADR_BASE = /u01/app/oracle
    OCI_RESULT_CACHE_MAX_SIZE= 2048000
    OCI_RESULT_CACHE_MAX_RSET_SIZE = 1024000
    NAMES.DIRECTORY_PATH = (EZCONNECT, TNSNAMES, HOSTNAME)
    The Databaseserver is configured like that:
    SQL> col name format a30
    SQL> col value format a30
    SQL> SELECT name, value
      2  FROM   v$system_parameter
      3  WHERE  name LIKE '%result_cache%';
    NAME                   VALUE
    result_cache_mode           MANUAL
    result_cache_max_size           0
    result_cache_max_result        5
    result_cache_remote_expiration 0
    client_result_cache_size       1073741824
    client_result_cache_lag        3000
    After configuring client an server I try the followign SQL-Statement on the clientmachine:
    sqlplus oracle/password@orcl
    set autotrace traceonly explain
    SELECT /*+ result_cache */ *
    FROM testtable;
    SQL
    The execution plan show two operations: "SELECT STATEMENT" and "TABLE ACCESS FULL" but no the "RESULT CACHE" operation.
    Did I miss something?
    Any help would be appreciated
    Florian W.

    result_cache_max_size           0
    That means the result cache is disabled. You need to set it to a non-zero value. That is the maximum ammount of memory, in bytes, the database will allocate on the shared pool to dedicate it to the result cache for all requests.
    By the way, OCI_RESULT_CACHE_MAX_SIZE is optional. By default the sessions will have the maximum size they can occupy on the cache determined by CLIENT_RESULT_CACHE parameter, the client (OCI) side parameters override that.
    result_cache_mode           MANUAL
    Another thing to consider is RESULT_CACHE_MODE in MANUAL, that will cause only the statements with the RESULT_CACHE hint on it to be cached on the result cache. You can also set result cache to mode FORCE on specific tables with alter table command.
    Regards

  • Using the client result cache without the query result cache

    I have constructed a client in C# using ODP.NET to connect to an Oracle database and want to perform client result caching for some of my queries.
    This is done using a result_cache hint in the query.
    select /*+ result_cache */ * from table
    As far as I can tell query result caching on the server is done using the same hint, so I was wondering if there was any way to differentiate between the two? I want the query results to be cached on the client, but not on the server.
    The only way I have found to do this is to disable all caching on the server, but I don't want to do this as I want to use the server cache for PL/SQL function results.
    Thanks.

    e3a934c9-c4c2-4c80-b032-d61d415efd4f wrote:
    I have constructed a client in C# using ODP.NET to connect to an Oracle database and want to perform client result caching for some of my queries.
    This is done using a result_cache hint in the query.
    select /*+ result_cache */ * from table 
    As far as I can tell query result caching on the server is done using the same hint, so I was wondering if there was any way to differentiate between the two? I want the query results to be cached on the client, but not on the server.
    The only way I have found to do this is to disable all caching on the server, but I don't want to do this as I want to use the server cache for PL/SQL function results.
    Thanks.
    You haven't provided ANY information about how you configured the result cache. Different parameters are used for configuring the client versus the server result cache so you need to post what, if anything, you configured.
    Post the code you executed when you set the 'client_result_cache_lag' and 'client_result_cache_size' parameters so we can see what values you used. Also post the results of querying those parameters after you set them that show that they really are set.
    You also need to post your app code that shows that you are using the OCI statements are used when you want to use client side result cacheing.
    See the OCI dev guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28395/oci10new.htm#sthref1491
    Statement Caching in OCI
    Statement caching refers to the feature that provides and manages a cache of statements for each session. In the server, it means that cursors are ready to be used without the need to parse the statement again. Statement caching can be used with connection pooling and with session pooling, and will improve performance and scalability. It can be used without session pooling as well. The OCI calls that implement statement caching are:
      OCIStmtPrepare2()
      OCIStmtRelease()

  • Client Result Cache Question

    Hi,
    i am not sure, whether the new feature "Client Result Cache" for OCI - Connections is an enterprise only feature or not.
    The Licensing Information at http://docs.oracle.com/cd/E11882_01/license.112/e10594/editions.htm#CJACGHEB shows this three features are enterprise only:
    Client Side Query Cache
    Query Results Cache
    PL/SQL Function Result Cache
    Which of these are pointing to Client Result Cache? Is it the Query Results Cache? Or something else?
    As an Hint, i am unable to activate the feature on standard edition databases, but i am not sure, if this is the reason or if i am just making some mistakes in configuration/testing.
    Thanks in advance
    Joerg

    we stopped all tests, because it seems to be a enterprise edition only feature.

  • Does Instant Client support client result caching?

    Hi all,
    couldn't find the answer to this question on the ic-FAQ (http://www.oracle.com/technetwork/database/features/oci/ic-faq-094177.html)
    Does Instant Client support client result caching?
    Kind regards, Sander.

    Yes. Like any other OCI feature, Client Result Caching is supported by Instant Client.
    Besides OCI documentation, here is a link to white paper on Client Result Caching and other OCI features: http://www.oracle.com/technetwork/topics/php/whatsnew/building-best-drivers-131920.pdf

  • Caching Result Set ?

    folks
    I have a search page which returns a result set and the results are put in the session to be able to access when user clicks on the page numbers(pagination) in the results pane.
    Is there any way we can store or cache this and access instead of fetching it off the session.

    You can store the data as a multi dimensional array in javascript on the rendered jsp page as a javascript function. It exists on the client side (browser) and you can use an onClick event on the page's button to call up various parts of the array and display it to the user. That way, your user doesnt have to submit the page back to the servlet to pagenate to the next page. The data shows up immidiately instead. You'll have to read up on javascript to learn how to do this. (Also I assume you are storing the resultant data in some type of array and not the raw resultSet).
    However, if so much data is returned to the user he needs pagenation, I suggest you add filter textfields to allow him to limit what data is returned so pagenation is not needed. Pagenation implies there is too much data for the user to effectively use at once (no one likes scrolling down a list of 200 items). For instance, instead of displaying all names in a list, add a filter so the user can search for all last names that begain with an A, or B, etc through Z. Then, when displayed to the user, show the list sorted by your filter criteria (lastName). If there is still too much data in the list, I suggest putting up a vertical scrollbar rather than pagenation.

  • Returning result sets from PL/SQL procedure to client app.

    I was wondering if its possible in Oracle PL/SQL to DECLARE, OPEN a cursor and exit
    the procedure without closing the cursor
    and then retrieve the resultset from
    the client.
    Pl let me know..
    null

    Yes, you need to use one OUT parameter in your PL/SQL procedure
    to pass the cursor variable to
    Java code. You can also return that as a return variable of
    PL/SQL function. Get the cursor variable from the resultset using
    Types.CURSOR data type and then proceed as usual.
    Enrique (guest) wrote:
    : Thank you Rajib for your prompt reply. I have been programming
    a
    : lot in Transact SQL( MSSQL ), but I am new to Oracle and I need
    : to migrate MSSQL procedures to Oracle. I will try to use the
    : refCursors. One more question, how do I pass the cursors back?
    : With OUT parameters? In MSSQL you do not need to specify OUT
    : parameters if you are returning a result set.
    : Once Again,
    : Thank you
    : Rajib (guest) wrote:
    : : You can return a variable of refcursor type from your PL/SQL
    : : procedure (PL/SQL 2.3 or higher) to Java code. Oracle JDBC
    has
    : a
    : : refcursor data type. Now you can use this cursor as a
    : resultset.
    : : Enrique (guest) wrote:
    : : : Hi All,
    : : : I am trying to write some store procedures( PL/SQL )
    : : that
    : : : will select rows from my tables, and then pass then back to
    : my
    : : : JDBC application as result sets....Does anyone know how can
    I
    : : do
    : : : that? Do I need to use output parameters? Or Return
    : functions?
    : : : Any help or hint wourl be be gladly appreciate it.
    : : : Enrique
    : : : Thank you.
    null

  • Olap cache not storing result sets for certain queries

    Hi - another cache question
    my result set for a query is not getting set in OLAP CACHE - the query variable level is stored ok but not the result set.
    different queries store the result sets ok.
    there is nothing in the query or cube properties that should disable the caching of the result set.
    there is plenty of space available and there has not been any changes to the query or data loaded or aggregates changed.
    any ideas?
    cheers - Neil

    I would do a performance check in RSRT2.  This will usually give you some additional information related to olap cache. 
    Hope that helps.

  • Client Result Cache for geometries

    Hi,
    we have experienced that Client Result Caches can not be used using SDO geometries or function calls. Does anybody know a workaround for using Client Result Caches with geometries (e.g. casting the geometries to varchar2).
    Thanks in advance,
    Simon

    There is a Spatial forum here at OTN. Please delete this thread and repost there.
    Thank you.

  • Client Result Cache

    Is it possible to use the Client Result Cache when you use ODP.NET?
    With the client side query cache it should be possible to cache query results in client memory.

    Is it possible to use the Client Result Cache when you use ODP.NET?
    Yes, absolutely. In fact, my next Oracle Magazine column is on just that subject... though you won't see it until the May/June 2008 issue is published.
    - Mark

  • Hide or Remove OCI Check Box column from Standard MDM Result Set iview

    Hi,
    Can we hide or remove the OCI Check box column from the Standard MDM Result set ivew?
    Though i have made OCI disabled, I dont want to display the check boxes along with the product list.
    Can you please help?
    Thanks and best regards,
    Arun prabhu S

    Hi Arun,
    If you are talking about the very first check box, then that is not related to OCI. Use of check box is to anable multiple item selection which can be used adding the records in the workflow, for comparison etc.
    Regards,
    Jitesh Talreja

  • Store result set in to cache

    i want to store some result set(select clause) into cache and reuse into latter part.
    kindly help me out.(oracle 10g)
    Edited by: anutosh on Oct 12, 2009 6:11 AM

    i am inserting value into 2 tables
    'INSERT INTO ' ||
    in_fct_table ||
    ' NOLOGGING SELECT * FROM ' ||
    in_fct_table ||
    '_STG PARTITION(' ||
    f_pop_partition.partition_name ||
    ') LOG ERRORS INTO ' ||
    in_fct_table ||
    '_D(''' ||
    f_pop_partition.partition_name ||
    ''') REJECT LIMIT UNLIMITED';
    duplicates data stored in <_ d> (suffix) table and remaining data(without duplicate) want to store in in_fct_tables(variable name) based on some partition.
    data from in_fct_tables(variable name) table want to populate into some other table . so for that we need to capture the data from in_fct_table.

Maybe you are looking for