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.

Similar Messages

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

  • How to get the query result of improvement (Before and After ) using sql de

    how to get the query result of improvement (Before and After ) using sql developer.

    Check
    http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html

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

  • Query result different with profit and loss statement

    Hi all,
    I run query Sum(JDT1.Debit - JDT1.Credit), and then compare the query result with the profit and loss statement, and there is different.
    The difference is about 0.01.
    At SAP, the Decimal places is set to 2.
    I already checked the data, and their amount in 2 decimal.
    Do anyone know such problem and what kind of query must I use so the result can be compared with the profit and loss statement ?
    Thx.

    Riny, 
    I am glad you found the issue
    Suda

  • Query results cached?

    For a report region, is the query results cached?
    That is, is the report query being executed again
    in the following condition:
    * when a user navigate between pages of a report
    (from page 1 (1-100 of 1000 rows) to page 2 (101-200 of 1000 rows)
    * when a user clicks on the column heading to sort the report

    Ken,
    In both cases the query is executed again.
    Regards,
    Marc

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

  • 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

  • Can I retrieve a result set from Oracle and then incorporate that result set into my main SQL Server Stored Procedure?

    So I have a chunk of data that only resides in Oracle. So I need to capture that information from Oracle. Now before you get over zealous, I did try with an OPENQUERY and it took FOREVER! And I don't know why the OPENQUERY took FOREVER but if I run the same
    query directly against Oracle it runs very quickly...like 20 seconds.
    So now I'm wondering...can I build a dataset in my SSRS Report that uses an Oracle Data source and an Oracle Stored Procedure in its Dataset that I'll create to aggregate this subset of data and then utilize its result set back in my main reporting
    Dataset that will utilize SQL Server? And how can I do that? Can I make my main Dataset reference, say, a #TemporaryTable that is created from my Oracle Dataset in its
    I'll continue to Google a few things as I await your review and hopefully a reply.
    Thanks in advance for your help.

    Hi ITBobbyP,
    According to your description you want to use data from a Oracle data source into a DataSet which retrieving data from SQL Server. Right?
    In Reporting Services, we can have multiple data sources in one project pointing to different database. And we can use separated dataset to retrieve data from different data source. However, it's not supported to combine the two datasets together
    directly. We can only use Lookup(), LookupSet() function to combine fields from different dataset into one tablix when there are common columns between two datasets. This is the only way to make tow result sets together in SSRS.
    Reference:
    Lookup Function (Report Builder and SSRS)
    LookupSet Function (Report Builder and SSRS)
    Best Regards, 
    Simon Hou
    TechNet Community Support

  • How to - extract query result set in CSV and make multiple files if result set is huge.

    I have a query which returns millions of rows. I need to extract those rows in CSV files. Having said that i want to keep these files under a limit of 500 MB . Result set can be distributed among multiples files but each file can not be > 500 MB in size.
    How to achieve this?

    You may use this standard! procedure from Blushadow and produce something useful for your need. https://community.oracle.com/message/6499123#6499123

  • SQL Result Cache  vs In-Memory Database Cache

    Hi,
    can anyone help me to understand the relations and differences between the 11 g new features of SQL Result Cache vs In-Memory Database Cache ?
    Thanks

    I highly recommend you read the 11g New Features Guide. Here is a sample from it:
    h4. 1.11.2.9 Query Result Cache
    A separate shared memory pool is now used for storing and retrieving
    cached results. Query retrieval from the query result cache is faster
    than rerunning the query. Frequently executed queries will see
    performance improvements when using the query result cache.
    The new query result cache enables explicit caching of results in
    database memory. Subsequent queries using the cached results will
    experience significant performance improvements.
    See Also:
    [Oracle Database Performance Tuning Guide|http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/memory.htm#PFGRF10121] for details
    [Results Cache Concepts|http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/memory.htm#PFGRF10121|Results Cache Concepts]
    HTH!

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

  • Is result cache, part of PGA or SGA(Shared Pool)

    Is result cache, part of PGA or SGA(Shared Pool). whats is its stand when is is in a dedicated server or a RAC environment

    Server query result cache can only be in SGA otherwise it could not be shared: http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/memory.htm#BGBGEACF
    Edited by: P. Forstmann on 28 sept. 2010 09:30

  • Does Result Cache Really Work..

    Does Result Cache Really Work..
    We have upgraded to 11.2.0.2 Theere were some corruption issue we were facing cause of using result cache..
    Still the same error after upgrade...
    Is any one here familiar with using result cache..One good thing about result cahce i found it does improve performance.
    But the problem is the datbaase crashes..after it reaches some memory limit..Does any one have good expereince using it..?

    Probably following notes on Oracle Support site can help.
    11g New Feature PL/SQL Function Result Cache [ID 430887.1]
    11g New Feature : SQL Query Result Cache [ID 453567.1]
    PL/SQL Procedures Do Not Switch Result Cache Mode Within The Same Session [ID 556035.1]
    HTH

Maybe you are looking for

  • How to load external javascript ie .js in jspx page

    hi, iam working on google maps ,Here there is a requirement of loading .js file in my page . As it is giving browserincompatible so i need to load one .js file var myscript='<scr'+'ipt src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAPo9X9pm

  • Sun LDAP to IDM synchronization issue

    Hello friends, I am trying to synchronize all the new accounts created in sun LDAP to IDM. It runs every 10 minutes as configured but does not pick the new user from LDAP. Here is the brief configuration detail. (1) I have switched on the "Retro Plug

  • Why do sites in Safari 6's reading list say "waiting"

    I'm running Lion (10.7.4). Ever since I upgraded to Safari 6, the sites listed in Reading List show a "Waiting..." attribute. This never goes away. Any solutions?

  • ICal crashed with one of two users -

    Hi ! My mac crashed last week and I was obliged to install it from scratch - I was happy to have a backup and save all of my data and those of my wife. But I cant use iCal with my account ! It only work with my wife account - I wonder if it's not bec

  • Hat "CS5 Extended" Zugriff auf "Ilustrator"?

    Ich besitze die Schüler/Studenten Version von Adobe Photoshop Cs5 Extended. Für meine Ausbildung benötige ich jetzt Adobe Illustrator. Meine Frage wäre, ob bei Cs5 Extended Illustrator nicht dabei ist? Oder ist dem nicht so? Wenn ja, wie kann ich es