Result Cache value

my table frequently updating value.I want to retrieve updated value from result cache not from the table .
I used result cache function for the same.updated value is coming from table and not updated value from result cache.
Is it possible to retrieve updated value from result cache.or any the memory area.
I have below query
SELECT /*+RESULT_CACHE*/SALARY FROM EMPLOYEES WHERE EMPLOYEE_ID = 160
at the first time above query retrieving value from the disk.
next time it is retrieving value from result cache. that is correct.
But whenever salary is updating for the employee_id =160.
after that that query retrieving value from disk. this is also correct.
But i want to retrieve value after update the salary for that employee_id=10 from result cache not from disk.I want to any mechanism is available in oracle that can retrieve value from result cache for the same input if record is updated.
Edited by: ibney on Mar 20, 2013 2:15 AM

Hi Karthick,
I know that .i have another question .
I have below query
SELECT /*+RESULT_CACHE*/SALARY FROM EMPLOYEES WHERE EMPLOYEE_ID = 160
at the first time above query retrieving value from the disk.
next time it is retrieving value from result cache. that is correct.
But whenever salary is updating for the employee_id =160.
after that that query retrieving value from disk. this is also correct.
But i want to retrieve value after update the salary for that employee_id=10 from result cache not from disk.I want to any mechanism is available in oracle that can retrieve value from result cache for the same input if record is updated.
Edited by: ibney on Mar 20, 2013 2:16 AM
Edited by: ibney on Mar 20, 2013 2:16 AM

Similar Messages

  • Oracle 11g/R2 Query Result Cache - Incremental Update

    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AM

    965300 wrote:
    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AMNo, the RESULT CACHE operation doesn't necessarily mean that the results are retrieved from there. It could be being
    written to there.
    Look at the number of consistent gets: it's zero in the first step (I assume you had already run this query before) and I would
    conclude that the data is being read from the result cache.
    In the third step there are 4 consistent gets. I would conclude that the data is being written to the result cache, a fourth step repeating
    the SQL should show zero consistent gets and that would be the results being read.

  • 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

  • Result Cache in oracle 11g release 2.0.2.0

    All,
    Few months back I was trying Result Cache feature of 11g release 2.0.1.0. That time oracle mentioned that they have 3 modes to use this feature by setting result_cache_mode paramter to AUTO, FORCE or MANUAL. With AUTO mode (result_cache_mode=AUTO) you can identify queries that may benefit from result cache. I would like to know whcih views or function I should see where it captures this information.
    In 11.2.0.1.0 documentation it was referencing some views (I totally don't remember those views names) and said those will be available in 11.2.0.2.0.
    Is anyone know about this?
    Thanks in advance.

    user2486753 wrote:
    Though oracle doc doesn't say about AUTO it is still accepts that value and caches the result of the SQL query if you add /*+ result cache */ hint to the SQL.
    I know that they did mentioned in 112010 some where that it will help users to find which SQL's are good candidates for caching by running the application for a while. I just couldn't fine it.If we are adding AUTO and still passing the hint, its the same behavior as like MANUAL. I am not sure that I have seen the value anywhere and neither its there in the docs too.
    HTH
    Aman....

  • Oracle result cache and functions

    Hi All,
    I am on 11.2 in Linux.
    I want to use Oracle's result cache to cache results of (user defined) functions, which we use in SELECT commands.
    My question is, does result caching work for deterministic and non-deterministic functions ?
    Just curious, how Oracle keeps track of changes being made which affect a function's return value?
    Thoughts please.
    Thanks in advance

    I want to ... cache results of (user defined) functions, which we use in SELECT commands.You have four choices:
    1. Subquery caching - (wrap function call in SELECT) useful for repeated function calls in a single SELECT
    2. Marking function as DETERMINISTIC - inconsistent results across versions, deterministic best reserved for function-based indexes only
    3. Result Cache
    4. Move function logic out of function and inline to the main SQL statement.
    The biggest downside of any function call that is inline to SQL is that it bypasses the read consistency mechanism, actually that's probably the second biggest downside. The biggest downside is normally that their misuse kills performance.
    If your function itself contains SQL then you should seriously reconsider whether you should be using a function.
    does result caching work for deterministic and non-deterministic functions ?Result cache knows nothing about determinism so yes it should be applied regardless.
    Oracle keeps track of changes being made which affect a function's return value?See v$result_cache_dependency.
    The mechanism is very blunt, there is no fine-grained tracking of data changes that may affect your result.
    It's as simple as function F1 relies on table T1. If the data in table T1 changes, invalidate the results in the result cache for F1.

  • If sga_target set explicitly, result cache become disabled

    hi all,
    I am using 11g R2 and automatic memory management. I realized something. if I explicitly declare sga_target parameter in parameter file, result cache become disabled.
    as you know if you use automatic memory management, sga_target is set to 0 automatically already but if I write that to the parameter file than whatever I set for result_cache_max_size parameter, instance always opens with result_cache_max_size=0 (I saw that in alert log).
    is there any reason for that ?
    here is my pfile contents.
    orcl.__db_cache_size=922746880
    orcl.__java_pool_size=33554432
    orcl.__large_pool_size=16777216
    orcl.__oracle_base='C:\app\paranoyakX'#ORACLE_BASE set from environment
    orcl.__pga_aggregate_target=838860800
    orcl.__sga_target=1258291200
    orcl.__shared_io_pool_size=0
    orcl.__shared_pool_size=251658240
    orcl.__streams_pool_size=16777216
    *.audit_file_dest='C:\app\paranoyakX\admin\orcl\adump'
    *.audit_trail='DB_EXTENDED'
    *.compatible='11.2.0.0.0'
    *.control_files='C:\app\paranoyakX\oradata\orcl\control01.ctl','C:\app\paranoyakX\flash_recovery_area\orcl\control02.ctl'
    *.db_16k_cache_size=0
    *.db_4k_cache_size=0
    *.db_block_size=8192
    *.db_domain='oracle.com'
    *.db_flashback_retention_target=1000
    *.db_keep_cache_size=0
    *.db_name='orcl'
    *.db_recovery_file_dest='C:\app\paranoyakX\flash_recovery_area'
    *.db_recovery_file_dest_size=10737418240
    *.diagnostic_dest='C:\app\paranoyakX'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
    *.memory_max_target=34359738368
    *.memory_target=2097152000
    *.nls_language='TURKISH'
    *.nls_territory='TURKEY'
    *.open_cursors=300
    *.pga_aggregate_target=528482304
    *.processes=150
    *.remote_login_passwordfile='EXCLUSIVE'
    *.resource_limit=TRUE
    *.undo_tablespace='UNDOTBS1'
    *.result_cache_max_size=5000000
    *.sga_target=0

    I would suggest that you pay more attention to documentation and don't jump to conclusion in a haste. Just because the parameter result_cache_max_size is set to 0, it does not mean that the result cache in itself is disabled. This is the maximum size of the result cache. See below,
    [oracle@edbar2p0-orcl ~]$ sqlplus / as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 14 08:35:00 2011
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options
    SQL> sho parameter result
    NAME                                 TYPE        VALUE
    client_result_cache_lag              big integer 3000
    client_result_cache_size             big integer 0
    result_cache_max_result              integer     5
    result_cache_max_size                big integer 1184K
    result_cache_mode                    string      MANUAL
    result_cache_remote_expiration       integer     0
    SQL> show parameter sga
    NAME                                 TYPE        VALUE
    lock_sga                             boolean     FALSE
    pre_page_sga                         boolean     FALSE
    sga_max_size                         big integer 460M
    sga_target                           big integer 0
    SQL> set autot trace exp
    selSQL> ect /*+ result_cache */ * from scott.dept;
    Execution Plan
    Plan hash value: 3383998547
    | Id  | Operation          | Name                       | Rows  | Bytes | Cost (
    %CPU)| Time     |
    |   0 | SELECT STATEMENT   |                            |     4 |    80 |     3
      (0)| 00:00:01 |
    |   1 |  RESULT CACHE      | 1c13q1afp56bq0jpnmysvywx7g |       |       |
         |          |
    |   2 |   TABLE ACCESS FULL| DEPT                       |     4 |    80 |     3
      (0)| 00:00:01 |
    Result Cache Information (identified by operation id):
       1 - column-count=3; dependencies=(SCOTT.DEPT); name="select /*+ result_cache
    */ * from scott.dept"
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing optionsThe value for the result_cache parameter is automatically set by oracle depending on either you have Memory_target/SGA_TARGET or Shared_Pool parameter set. Please see oracle documentation for more information.
    HTH
    Aman....

  • 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.

  • Result cache not working?

    Hi,
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> show parameter result;
    NAME TYPE VALUE
    client_result_cache_lag big integer 3000
    client_result_cache_size big integer 0
    result_cache_max_result integer 5
    result_cache_max_size big integer 10M
    result_cache_mode string MANUAL
    result_cache_remote_expiration integer 0
    The above are the initialization parameters set and the DB version.
    Now i have created a table as
    create table objects as select * from dba_objects;
    then issued the following query.
    select /* result_cache */ object_Type,count(*) from objects group by object_type;
    it appears that the results of the above query is not cached in the result cache. using
    set autotrace traceonly explain confirms that there is no result cache or the CACHE_ID in the explain plan. also the v$result_cache_statistics confirm the same.
    But after this when i issued the following statement.
    alter session set result_cache_mode=force;
    the same below sql statement again
    select /* result_cache */ object_Type,count(*) from objects group by object_type;
    it appears that now the result cache is being used.
    My question is despite using the result_cache hint and trying the above statement when the result_cache_mode=auto/manual. The result cache is not being used or the results of the SQL statements are not being cached at all despite using the result_cache hint and the table being not used at all. and if i use the result_cache_mode=force then the result cache is being used.
    Can any one please explain this behavior. Cursor_sharing is set to EXACT. and i am issuing the same SQL statement without any changes at all.
    Thanks,

    There is a syntax problem with your queries:
    select /* result_cache */.... is just a comment, not a hint. For creating a hint, you need "+": select /*+ result_cache */....

  • Result cache invalidated

    Hi,
    Oracle version 11.2.0.1 on Linux
    I understand thatt result cache (RC) invalidation is at table level.
    I did a simple test:
    create table customer (custno number, custname varchar2(30));
    Table created.
    insert into customer (custno,custname) values (1,'Customer_1');
    insert INTO CUSTOMER (custno,custname) values (2,'Customer_X');
    select * from customer;
        CUSTNO CUSTNAME
             1 Customer_1
             2 Customer_X
    commit;
    Commit complete.Now I invoke result cache here
    select /*+ RESULT_CACHE */ * FROM customer where custno=1;
    Execution Plan
    Plan hash value: 2844954298
    | Id  | Operation          | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                            |     1 |    30 |     3   (0)| 00:00:01 |
    |   1 |  RESULT CACHE      | ggb2vz6jcvcn5ajzqh406j3n85 |       |       |            |          |
    |*  2 |   TABLE ACCESS FULL| CUSTOMER                   |     1 |    30 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("CUSTNO"=1)
    Result Cache Information (identified by operation id):
       1 - column-count=2; dependencies=(SCRATCHPAD.CUSTOMER); name="select /*+ RESULT_CACHE */ * FROM customer where custno=1"Invoke RC for second row query
    select /*+ RESULT_CACHE */ * FROM customer where custno=2;
    Execution Plan
    Plan hash value: 2844954298
    | Id  | Operation          | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                            |     1 |    30 |     3   (0)| 00:00:01 |
    |   1 |  RESULT CACHE      | fc8t6svvz6whh0gc8vcaxrh668 |       |       |            |          |
    |*  2 |   TABLE ACCESS FULL| CUSTOMER                   |     1 |    30 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("CUSTNO"=2)
    Result Cache Information (identified by operation id):
       1 - column-count=2; dependencies=(SCRATCHPAD.CUSTOMER); name="select /*+ RESULT_CACHE */ * FROM customer where custno=2"OK they are stored as separate result cache
    Now update the second row in that table in another session
    update customer set custname ='Customer_2' where custno=2;
    1 row updated.
    commit;
    Commit complete.Now query custno=2 from the first session
    select /*+ RESULT_CACHE */ * FROM customer where custno=2;
    Execution Plan
    Plan hash value: 2844954298
    | Id  | Operation          | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                            |     1 |    30 |     3   (0)| 00:00:01 |
    |   1 |  RESULT CACHE      | fc8t6svvz6whh0gc8vcaxrh668 |       |       |            |          |
    |*  2 |   TABLE ACCESS FULL| CUSTOMER                   |     1 |    30 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("CUSTNO"=2)
    Result Cache Information (identified by operation id):
       1 - column-count=2; dependencies=(SCRATCHPAD.CUSTOMER); name="select /*+ RESULT_CACHE */ * FROM customer where custno=2"The same result cache reference is still there. So does this mean that result cache is NOT invalidated despite the row being updated or I am doing something wrong here?
    Thanks
    Edited by: 902986 on 12-Feb-2012 13:26

    The result cache id is a hash value for the query so that Oracle can later tell if a query will produce a result set that is already in the cache.
    When you updated the table the result set in the cache was marked invalid. Then you ran the same query for record 2 and Oracle created a hash value for the query and the hash value is the same as the first time since the query is the same; that is, the query itself hashes to the same value. But the result cache contents for that query have changed and replace the old invalid contents.
    If you query the result set cache you will get the new value not the old one since the old result set for your second query isn't there anymore.

  • Result Cache Oracle 11gR2

    Hi all,
    Currently I have some problems with result cache, or maybe I don't understand this feature properly.
    I'm trying to switch off the bypass mode, and I'm not able to do this:
    SQL> select dbms_result_cache.status from dual;
    STATUS
    BYPASS
    SQL> exec dbms_result_cache.bypass(FALSE);
    PL/SQL procedure successfully completed.
    SQL> select dbms_result_cache.status from dual;
    STATUS
    BYPASS
    SQL> show parameter result
    NAME TYPE VALUE
    client_result_cache_lag big integer 3000
    client_result_cache_size big integer 0
    result_cache_max_result integer 5
    result_cache_max_size big integer 0
    result_cache_mode string MANUAL
    result_cache_remote_expiration integer 0
    SQL> alter system set result_cache_max_size=2M scope=both;
    System altered.
    SQL> show parameter result
    NAME TYPE VALUE
    client_result_cache_lag big integer 3000
    client_result_cache_size big integer 0
    result_cache_max_result integer 5
    result_cache_max_size big integer 0
    result_cache_mode string MANUAL
    result_cache_remote_expiration integer 0
    SQL> alter system set result_cache_max_size=2M scope=spfile;
    System altered.
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup
    ORACLE instance started.
    Total System Global Area 523108352 bytes
    Fixed Size 1337632 bytes
    Variable Size 465569504 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5869568 bytes
    Database mounted.
    Database opened.
    SQL> show parameter result
    NAME TYPE VALUE
    client_result_cache_lag big integer 3000
    client_result_cache_size big integer 1G
    result_cache_max_result integer 5
    result_cache_max_size big integer 0
    result_cache_mode string MANUAL
    result_cache_remote_expiration integer 0
    SQL> select dbms_result_cache.status from dual;
    STATUS
    BYPASS
    SQL> set serveroutput on;
    SQL> exec dbms_result_cache.memory_report
    R e s u l t C a c h e M e m o r y R e p o r t
    [Parameters]
    Block Size = 1K bytes
    Maximum Cache Size = 0 bytes (0 blocks)
    Maximum Result Size = 0 bytes (0 blocks)
    [Memory]
    Total Memory = 9440 bytes [0.004% of the Shared Pool]
    ... Fixed Memory = 9440 bytes [0.004% of the Shared Pool]
    ... Dynamic Memory = 0 bytes [0.000% of the Shared Pool]
    PL/SQL procedure successfully completed.
    SQL>
    Is there something what I missed?
    Thanks for any advices.
    Regards,
    Piotr

    A little bit more theory:
    The result cache resides in the Shared pool. Because the database was managing its memory automatically (parameter memory_target was set) and no one was working with this environment, the database didn't allocate yet enough space for shared pool to give some space for result cache. I had to set min value for shared pool to force the database to automatically allocate some space to shared pool during start up and never make shared pool smaller than specified value.
    Hope that this explanation help other people :)
    Regards,
    Petrus

  • 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()

  • PL/SQL Function Result Cache?

    Hi all,
    As we know, there's a new feature in 11g, called 'result cache', this 'result cache' can be shared throughout the whole instance, but if I got it right, only sql query result and function return value are cached, right? how about the store procedure, I mean, procedure also has its 'return value'--the output parameter, could it benefit from this new feature?
    Another question is, if my PL/SQL Function just retrieves the table and returns the result without any complicated calculation, is it necessary to enable the 'result cache' mechanism on this Function? because we already have 'db buffer cache' if the only thing we do is to query tables.
    Many thanks.

    Hi Morven,
    As of now, PL/SQL Result cache feature is only enabled for stored functions and not for procedures. This is due to the objectives they achieve. Functions are usually computative and procedures are for logic implementation.
    And for enabling result caching feature for a function, you are the better judge as u can test the performance in both the case. But, i would support enabling the cache because oracle 11g provides Cache as a different SGA component. db_buffer_cache will also be used for buffering other data blocks and not the result sets.
    Hope my explanation is fine.

  • Result Caching in OSB

    We are planning to implement OSB result caching feature in our project.We did the following to do a POC.
    1.Created a DBAdapter to select from a table and created a BS out of that.
    2.Enabled Result caching with TTL for 5 mins.
    3.Invoked the BS from a PS.
    4.Tested the PS by invoking from test cosnole.
    5.Response was received as expected.
    6.Changed the value in the table and tested again within 5 mins.
    7.New values were returned instead of the ones in the cache.
    What might be the problem?Should it not return the old value from table?

    Each cached result is uniquely identified by a cache key that is made up of the ServiceRef (the unique identifier for the service which is the fully qualified path name of the service), the operation being invoked, and a cache token String. The cache token helps to uniquely identify a single cache result among other cache results for one business service. You control the value of the cache token. You can set the cache token either by configuring the Cache Token expression in the Result Caching configuration for the business service or by using the cache-token metadata element in the $transportMetaData using the proxy service message flow. If there is no cache-token defined then caching may not work as expected.
    Please refer -
    35.7.5 Improving Performance by Caching Business Service Results at http://download.oracle.com/docs/cd/E17904_01/doc.1111/e15867/configuringandusingservices.htm#CHDDCGEE
    http://blogs.oracle.com/MarkSmith/2011/03/osb_and_coherence_integration_1.html
    Regards,
    Anuj

  • Result cache doubt

    what is the difference if i write relies_on clause or if i dont write it, technically please explain what exactly is the difference ??
    create or replace function tax (i in varchar2)
    return number
    result_cache
    is
    begin
    return i*0.08 ;
    end;
    create or replace function tax (i in varchar2)
    return number
    result_cache relies_on (emp)
    is
    begin
    return i*0.08 ;
    end;

    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/function.htm#i34368
    RELIES_ON
    Specifies the data sources on which the results of a function depend. For more information, see Using the PL/SQL Function Result Cache. http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/subprograms.htm#BABFHACJ
    To enable result-caching for a function, use the RESULT_CACHE clause. When a result-cached function is invoked, the system checks the cache. If the cache contains the result from a previous call to the function with the same parameter values, the system returns the cached result to the invoker and does not reexecute the function body. If the cache does not contain the result, the system executes the function body and adds the result (for these parameter values) to the cache before returning control to the invoker.Not sure why are you talking about invalidated data, result_cache just invoked result from a previous call to the function if it exists, if not it executes the function body.
    The clause relies_on just specifies the data sources on which the results of a function depend.
    am i missing something??

  • Result cache question

    I create and populate the following table in my schema:
    create table plch_table (id number, time_sleep number);
    begin
      insert into plch_table values (1, 20);
      commit;
    end;
    Then I create this function (it compiles successfully, since my schema has EXECUTE authority on DBMS_LOCK):
    create or replace function plch_func
      return number
      result_cache
    is
      l_time_sleep number;
    begin
      select time_sleep
        into l_time_sleep
        from plch_table
       where id = 1;
      dbms_lock.sleep(l_time_sleep);
      return l_time_sleep;
    end;
    I then start up a second session, connected to the same schema, and execute this block:
    declare
      res number := plch_func;
    begin
      null;
    end;
    Within five seconds of executing the above block, I go back to the first session and I run this block:
    declare
      t1 number;
      t2 number;
    begin
      t1 := dbms_utility.get_time;
      dbms_output.put_line(plch_func);
      t2 := dbms_utility.get_time;
      dbms_output.put_line('Execute in '||round((t2-t1)/100)||' seconds');
    end;
    what will be displayed after this block executes?
    And the result is:
    20
    Execute in 30 secondsHowever, I don't understand why? I mean what is going on behind this? Why the result 30? Could somebody tell me why?

    Honestly, before yesterday's PL/SQL Challenge question, I had no idea how this worked either. This is very much a deep internals question-- you'd likely have to go looking for a very specialized presentation or blog post to get more detail (or you'd have to do the research yourself). And even then, it's relatively unlikely that they would go into much more detail than the PL/SQL Challenge answer did. Julain Dyke's Result Cache Internals (PPT) is probably one of the more detailed presentations about the internals of the result cache.
    The set of valid statuses for a result cache object are documented in the Oracle Database Reference entry for the v$result_cache_objects view. The two 10 second timeouts are controlled by the database- and session-level settings of the undocumented resultcache_timeout parameter (which, based on this blog post by Vladimir Begun was set to 60 seconds in 11.1.0.6 and changed to 11.1.0.7 to 10 seconds.
    Justin

Maybe you are looking for

  • Unit of measurement in project system

    Hi Experts, Its relevant to PS module. Base unit of material is KG whereas sales unit is M2 and conversion is maintained between both. Now I am using sale unit (M2) while entering material componenets in project. Then I am raising PR, PO, GR in proje

  • Mac mini sleeping/waking problems

    Hello everyone, I'm experiencing constant issues with my mac mini. To awake it from sleep I have to push the power button, the screen goes grey with a progress bar display - not unlike on my macbook pro when resuming from low batteries - and all the

  • Cant burn a cd getting error 4280

    Keep getting error 4280 when trying to burn a music cd. Wht is the fix - suggestions?

  • THIRD PARTY ORDERING

    HI SAP GURUS CAN ANY ONE HELP ME OUT 1.     WHAT IS THIRD PARTY ORDERING? HOW WE CONFIGURE THIRD PARTY ORDERING ?  DOES DELIVERY OCCURS IN THIRD PARTY ORDERING? WHEN 2.     IF I HAVE GOT 4PLANTS HTEN HOW MANY BILLING CAN BE DONE? 3. AFTER PGI WHAT HA

  • Compressor keeps crashing and quitting.

    Hi, Compressor was working fine till yesterday. Now it either quits or crashed everytime, and Im not able to do anything in it. Even when I drop some small project movie, etc. It acts really really slow, gives the spinning wheel for long periods, and