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.

Similar Messages

  • Oracle 11g result cache and TimesTen

    Oracle 11g has introduced the concept of result cache whereby the result set of frequently executed queries are stored in cache and used later when other users request the same query. This is different from caching the data blocks and exceuting the query over and over again.
    Tom Kyte calls this just-in-time materialized view whereby the results are dynamically evaluated without DBA intervention
    http://www.oracle.com/technology/oramag/oracle/07-sep/o57asktom.html
    My point is that in view of utilities like result_cache and possible use of Solid State Disks in Oracle to speed up physical I/O etc is there any need for a product like TimesTen? It sounds to me that it may just asdd another layer of complexity?

    Oracle result cache ia a useful tool but it is distinctly different from TimesTen. My understanding of Oracle's result cache is caching results set for seldom changing data like look up tables (currencies ID/code), reference data that does not change often (list of counter parties) etc. It would be pointless for caching result set where the underlying data changes frequently.
    There is also another argument for SQL result cache in that if you are hitting high on your use of CPUs and you have enough of memory then you can cache some of the results set thus saving on your CPU cycles.
    Considering the arguments about hard wired RDBMS and Solid State Disks (SSD), we can talk about it all day but having SSD does not eliminate the optimiser consideration for physical I/O. A table scan is a table scan whether data resides on SCSI or SSD disk. SSD will be faster but we are still performing physical IOs.
    With regard to TimesTen, the product positioning is different. TimesTen is closer to middletier than Oracle. It is designed to work closely to application layer whereas Oracle has much wider purpose. For real time response and moderate volumes there is no way one can substitue TimesTen with any hard wired RDBMS. The request for result cache has been around for sometime. In areas like program trading and market data where the underlying data changes rapidly, TimesTen will come very handy as the data is real time/transient and the calculations have to be done almost realtime, with least complications from the execution engine. I fail to see how one can deploy result cache in this scenario. Because of the underlying change of data, Oracle will be forced to calculate the queries almost everytime and the result cache will be just wasted.
    Hope this helps,
    Mich

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

  • Query result cache with functions

    Hi all,
    one of my colleagues has found a little bit weird behavior of a query result cache. He has set result_cache_mode = 'FORCE' (but it can be reproduced with a result_cache hint too) and suddenly functions called from the query get executed twice (for the first time) .
    An easy example:
    alter session set result_cache_mode = 'FORCE';
    create sequence test_seq;
    create or replace function test_f(i number)
    return number
    is                  
    begin
      dbms_output.put_line('TEST_F executed');
      --autonomous transaction or package variable can be used too
      return test_seq.nextval;
    end;
    prompt First call
    select test_f(1) from dual;
    prompt Second call
    select test_f(1) from dual;
    drop sequence test_seq;
    drop function test_f;
    First call
    TEST_F(1)
             2
    TEST_F executed
    TEST_F executed
    Second call
    TEST_F(1)
             1
    As you can see - for the first time the function is executed twice and return the value from the second execution. When I execute the query again it returns the value from the first execution... but it doesn't matter, problem is in the double execution. Our developers used to send emails via select (it's easier for them):
    select send_mail(...) from dual;
    ... and now the customers complains that they get emails twice
    And now the question - is there any way, hot to get rid of this behavior (without changing the parameter back or rewriting code)? I thought that the result cache is automatically disabled for non-deterministic functions...or is this an expected behavior?
    Thanks,
    Ivan

    Interesting.. you are right:
    SELECT /*+ RESULT_CACHE */ 'dog' FROM DUAL;
    And at the second execution:
    | Id  | Operation        | Name                       | Rows  | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |                            |     1 |     2   (0)| 00:00:01 |
    |   1 |  RESULT CACHE    | cc5k01xyqz3ypf9t0j28r5gtd1 |       |            |          |
    |   2 |   FAST DUAL      |                            |     1 |     2   (0)| 00:00:01 |
    Hmmm..

  • Oracle Web Cache and OBIEE 11g

    Anyone using Oracle Web Cache with OBIEE 11g?
    Can I get an insight into whether this solution is beneficial? Or I shouldn't even bother.

    No iam not using oracle web cache
    Can I get an insight into whether this solution is beneficial? Or I shouldn't even bother.I dont have idea about it,but i think its not beneficial ,anyways there is OBIEE cache that is more than sufficient.
    hope answered your question.
    Cheers,
    KK

  • 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

  • Oracle Web Cache - Load Balancer Mode

    Hello,
    I am facing a problem related to fault tolerance in Oracle Web Cache
    My environment:
    2 Nodes of Oracle Application Server 10.1.3 configured in cluster.
    have configured Oracle Web Cache (in LoadBalancer mode only) to simulate a BigIP load balancing above these two oc4j node. This to be used as fault tolerance so if one http request will fail the LoadBalancer will direct it to the second oc4j (its http server).
    I have used the defaults recommended by Oracle documentation for configuration clustering load balancer using Oracle Web Cache and using JSESSIONID for Session binding with oc4j-type. I left all other cluster/server setting to default
    Problem:
    The problem is when I am shutting down one oc4j instance the Oracle Web Cache tries to keep the session with the un-available oc4j node and not direct the session to the other oc4j node.
    If I choose to start a new session (loose current work) than it does work with the second (alive) oc4j node, but than where is its fault tolerance??
    What do i need to do to keep working with the same session over the second oc4j node. My deployed Web App is enabled to work in cluster, using Oracle Application Server console. Here is its orion-application.xml
    +<?xml version="1.0"?>+
    +<orion-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-application-10_0.xsd" deployment-version="10.1.3.1.0" default-data-source="jdbc/OracleDS" component-classification="external"+
    schema-major-version="10" schema-minor-version="0" >
    +     <web-module id="session_rep" path="session_rep.war" />+
    +     <persistence path="persistence" />+
    +     <principals path="principals.xml" />+
    +     <jazn provider="XML" />+
    +     <log>+
    +          <file path="application.log" />+
    +     </log>+
    +     <cluster allow-colocation="false">+
    +     <replication-policy trigger="onRequestEnd" scope="modifiedAttributes"/>+
    +     <flow-control-policy enabled="false" />+
    +          <protocol>+
    +               <peer>+
    +                              <opmn-discovery/>+
    +               </peer>+
    +          </protocol>+
    +     </cluster>+
    +</orion-application>+
    Will appreciate any help !

    is OHS/apache deployed between web cache and your OC4J? if so, i think since OHS/apache is alive to web cache, web cache keeps routing to it.
    maybe in your script, you can shutdown both OHS/apache and OC4J totgether so web cache can correctly route.

  • Function result Cache in oracle 11G

    Hi,
    i am reading the following article and trying to reproduce same set of statements to learn about function result cache.
    http://www.oracle.com/technology/oramag/oracle/07-sep/o57asktom.html
    Details about my output:
    SQL> create or replace
    function not_cached
    ( p_owner in varchar2 )
    return number
    as
    l_cnt number;
    begin
    select count(*)
    into l_cnt
    from t
    where owner = p_owner;
    sys.dbms_lock.sleep(1);
    return l_cnt;
    end;
    Function created.
    Elapsed: 00:00:00.13
    SQL> create or replace
    function cached
    ( p_owner in varchar2 )
    return number
    result_cache
    relies_on(T)
    as
    l_cnt number;
    begin
    select count(*)
    into l_cnt
    from t
    where owner = p_owner;
    dbms_lock.sleep(1);
    return l_cnt;
    end;
    Function created.
    Elapsed: 00:00:00.08
    SQL> exec dbms_output.put_line( not_cached( 'SCOTT' ) );
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.06
    SQL> exec dbms_output.put_line( not_cached( 'SCOTT' ) );
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.01
    SQL> SQL> exec dbms_output.put_line( not_cached( 'SCOTT' ) );
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.02
    SQL> SQL> set serveroutput on
    SQL> exec dbms_output.put_line( not_cached( 'SCOTT' ) );
    0
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.02
    SQL> SQL> exec dbms_output.put_line( cached( 'SCOTT' ) );
    0
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.02
    SQL> SQL> exec dbms_output.put_line( cached( 'SCOTT' ) );
    0
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.02
    SQL> SQL> exec dbms_output.put_line( cached( 'SCOTT' ) );
    0
    PL/SQL procedure successfully completed.
    SQL> exec dbms_output.put_line( cached( 'SCOTT' ) );
    0
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.01
    I am supposed to get the results quickly for "cached" call. However, i still dont see any change in the response time. May i know what i am missing here?
    Thank you
    Giridhar

    Try to play with
    RESULT_CACHE_MAX_SIZE
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28320/initparams206.htm#REFRN10272
    RESULT_CACHE_MAX_RESULT
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28320/initparams205.htm#REFRN10298

  • Query result caching on oracle 9 and 10 vs indexing

    I am trying to improve performance on oracle 9i and 10g.
    We use some queries that take up to 30 minutes to execute.
    I heard that there are some products to cache query results.
    Would this have any advantage over using indexes or materialized views?
    Does anyone know any products that I can use to cache the results of this queries on disk?
    Personally I think that by using the query result caching I would reduce the cpu time needed to process the query.
    Is this true?

    Your message post pushes all the wrong buttons starting with the fact that 9i and 10g are marketing labels not version numbers.
    You don't tune queries by spending money and throwing resources at them. You tune them by identifying the problem queries, running explain plans, visualizing their output using DBMS_XPLAN, and addressing the root cause.
    If you want help post full version numbers, the SQL statements, and the DBMS_XPLAN outputs.

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

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

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

  • Replacing Oracle's FIRST_VALUE and LAST_VALUE analytical functions.

    Hi,
    I am using OBI 10.1.3.2.1 where, I guess, EVALUATE is not available. I would like to know alternatives, esp. to replace Oracle's FIRST_VALUE and LAST_VALUE analytical functions.
    I want to track some changes. For example, there are four methods of travel - Air, Train, Road and Sea. Would like to know traveler's first method of traveling and the last method of traveling in an year. If both of them match then a certain action is taken. If they do not match, then another action is taken.
    I tried as under.
    1. Get Sequence ID for each travel within an year per traveler as Sequence_Id.
    2. Get the Lowest Sequence ID (which should be 1) for travels within an year per traveler as Sequence_LId.
    3. Get the Highest Sequence ID (which could be 1 or greater than 1) for travels within an year per traveler as Sequence_HId.
    4. If Sequence ID = Lowest Sequence ID then display the method of travel as First Method of Travel.
    5. If Sequence ID = Highest Sequence ID then display the method of travel as Latest Method of Travel.
    6. If First Method of Travel = Latest Method of Travel then display Yes/No as Match.
    The issue is cells could be blank in First Method of Travel and Last Method of Travel unless the traveler traveled only once in an year.
    Using Oracle's FIRST_VALUE and LAST_VALUE analytical functions, I can get a result like
    Traveler | Card Issue Date | Journey Date | Method | First Method of Travel | Last Method of Travel | Match?
    ABC | 01/01/2000 | 04/04/2000 | Road | Road | Air | No
    ABC | 01/01/2000 | 15/12/2000 | Air | Road | Air | No
    XYZ | 01/01/2000 | 04/05/2000 | Train | Train | Train | Yes
    XYZ | 01/01/2000 | 04/11/2000 | Train | Train | Train | Yes
    Using OBI Answers, I am getting something like this.
    Traveler | Card Issue Date | Journey Date | Method | First Method of Travel | Last Method of Travel | Match?
    ABC | 01/01/2000 | 04/04/2000 | Road | Road | <BLANK> | No
    ABC | 01/01/2000 | 15/12/2000 | Air | <BLANK> | Air | No
    XYZ | 01/01/2000 | 04/05/2000 | Train | Train | <BLANK> | No
    XYZ | 01/01/2000 | 04/11/2000 | Train | <BLANK> | Train | No
    Above, for XYZ traveler the Match? clearly shows a wrong result (although somehow it's correct for traveler ABC).
    Would appreciate if someone can guide me how to resolve the issue.
    Many thanks,
    Manoj.
    Edited by: mandix on 27-Nov-2009 08:43
    Edited by: mandix on 27-Nov-2009 08:47

    Hi,
    Just to recap, in OBI 10.1.3.2.1, I am trying to find an alternative way to FIRST_VALUE and LAST_VALUE analytical functions used in Oracle. Somehow, I feel it's achievable. I would like to know answers to the following questions.
    1. Is there any way of referring to a cell value and displaying it in other cells for a reference value?
    For example, can I display the First Method of Travel for traveler 'ABC' and 'XYZ' for all the rows returned in the same column, respectively?
    2. I tried RMIN, RMAX functions in the RDP but it does not accept "BY" clause (for example, RMIN(Transaction_Id BY Traveler) to define Lowest Sequence Id per traveler). Am I doing something wrong here? Why can a formula with "BY" clause be defined in Answers but not the RPD? The idea is to use this in Answers. This is in relation to my first question.
    Could someone please let me know?
    I understand that this thread that I have posted is related to something that can be done outside OBI, but still would like to know.
    If anything is not clear please let me know.
    Thanks,
    Manoj.

  • Oracle 11g Result Cache

    Hi,
    I have read that there is SGA component called Result Cache. According to documentation:
    The result cache buffers query results. If a query is run that
    already has results in the result cache, the database returns
    results from the result cache instead of rerunning the query. This
    speeds up the execution of frequently run queries.
    What happens when data in tables which are called by the query change. I think the old data still will be in cache and I always get the old data.
    Peter D.

    Hi Peter
    What happens when data in tables which are called by
    the query change. I think the old data still will be in
    cache and I always get the old data.The server result cache can return old data only for distributed queries (i.e. queries also retrieving data from other databases).
    All local queries return the correct data. To do so, the cache entries are invalidated as required.
    HTH
    Chris Antognini
    Author of Troubleshooting Oracle Performance, Apress 2008 (http://top.antognini.ch)

  • 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

Maybe you are looking for