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)
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 -
From the oracle documentation, http://docs.oracle.com/cd/E11882_01/server.112/e10701/original_export.htm#BABJHCDH
it says that sequence numbers that have been allocated are available for use in the current database.
I have a table Test which has a column test_id having a sequence test_sequence.
Max value in the test_id is 20 and assume if test_sequence is cached for 20 in a 2 RAC node with each node caching numbers from 20-30 and 30-40.
If I do an export and import the sequences to a new database, will my next sequence number in the new database be 41 ?
If so, what will be the LAST_NUMBER in the dba_Sequences table in the source database.
Thanks in advance.Hi,
if you set CACHE 20 in a RAC environment each node will cache 20 number. In your case - cached numbers will be 21-40 and 41-60 and the dba_sequences.last_number=60.
If you do export/import all the cached numbers will be lost and your first number will be last_number+1. -
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 advanceI 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. -
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. -
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 AM965300 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
GiridharTry 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 -
How to Enable Result Cache in 11g XE ?
Does anyone know how to enable the result cache in 11g XE?
I've tired startup/shut down immediate with various ALTER SYSTEM commands (see below) but result_cache_max_size still defaults to zero when the database comes back up.
ALTER SYSTEM SET result_cache_max_size = 2M SCOPE = SPFILE;
ALTER SYSTEM SET result_cache_max_size = 2M SCOPE = BOTH;
ALTER SYSTEM RESET result_cache_max_size SCOPE = SPFILE SID='*';
Any advice would be helpful.
ThanksIn the [Licensing document|http://download.oracle.com/docs/cd/E11882_01/license.112/e10594/editions.htm#CJACGHEB] , in the 'performance' section of the table, the result cache is only available on Enterprise and not Standard, so I wouldn't expect it to work in Express Edition
-
Installing using the GUI works fine. I'm using the following code to perform the silent installation of the oracle client: C:\temp_pyx\Oracle source\3-Oracle 11G Express\setup.exe /S /f1"C:\temp_pyx\Oracle source\3-Oracle 11G Express\response\OracleXe-install.iss" /f2 "c:\windows\logs\paychex\oracle11ginstall.log"
Result code in "oracle11gisntall.log" shows "result = 3"
response file is configured as follows:
** Response file to perform silent install of Oracle Database 11g Express Edition **
** Values for the following variables are configurable: **
** szDir - Provide a valid path **
** TNSPort - Provide any valid available port number **
** MTSPort - Provide any valid available port number **
** HTTPPort - Provide any valid available port number **
** SYSPassword - Provide a valid password string **
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-DlgOrder]
Dlg0={05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdWelcome-0
Count=7
Dlg1={05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdLicense2Rtf-0
Dlg2={05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdComponentDialog-0
Dlg3={05A7B662-80A3-4EB9-AE1D-89A62449431C}-AskPort-13013
Dlg4={05A7B662-80A3-4EB9-AE1D-89A62449431C}-AskSYSPassword-13011
Dlg5={05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdStartCopy-0
Dlg6={05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdFinish-0
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdWelcome-0]
Result=1
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdLicense2Rtf-0]
Result=1
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdComponentDialog-0]
szDir=C:\programdata\oraclexe
Component-type=string
Component-count=1
Component-0=DefaultFeature
Result=1
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-AskPort-13013]
TNSPort=1521
MTSPort=2031
HTTPPort=8080
Result=1
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-AskSYSPassword-13011]
SYSPassword="Intentionally left blank"
Result=1
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdStartCopy-0]
Result=1
[{05A7B662-80A3-4EB9-AE1D-89A62449431C}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0I only see the following folders after install, which tells me that although the program shows up in program and features, it is still not successfully installed?
-
Result Cache hint in Oracle 11 g
I have a problem with the RESULT_CACHE hint , this has been used in the various function in our database e.g
Function xyz (input IN table1.col1%type)
RETURN BOLEAN
RESULT_CACHE
AS
DATE_VALUE DATE;
BEGIN
SELECT x INTO DATE_VALE FROM TABLE2 WHERE COLUMN3=INPUT;
IF DATE_VALUE <SYSDATE
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
EXCEPTION WHEN NO_DATA_FOUND
THEN
RETURN FALSE;
END;
Now the value of DATE_VALUE is fetched in stored in cache, based on the input . but the value of DATE_value is changed after some db operations .
Oracle will return the same value even after the value has been changed for the same input (assume that the true/false is changed after the date_value is changed. )
So clearly in this function RESULT_CACHE has not been used correctly.
what could be the solution for this , Result_cache has been used in 20+ function and code change is not possible at this time.
can we use DBMS_RESULT_CACHE.BYPASS(TRUE) ;
is it at instance level , or session level. we will be running oracle job using the procedure which uses this function ,so before each job do we need to run this pkg.(DBMS_RESULT_CACHE.BYPASS(TRUE)) ?
we do not want to use FLUSH as we will have to do it every time before the job runs .
or any other solution .
DATABASE Details are :
Oracle 11g Enterprise edition 11.1.0.7.0- 64 bit
HPUX version 11.1.0.7.0Su**** wrote:
Yes Tubby you are correct,
removing the result_cache from function is the permanent solution here,
But I want to know if anyone have encountered the same problem and use the BYPASS ,FLUSH etc to get a temporary solution . Thanks much.Your application has a bug. It has a bug because your developers didn't have time, or didn't care to read the documentation and understand what they were doing.
Why would you not want to fix that bug, choosing a workaround that may or may not work, and may or may not have undesired side effects on other portions of your application when the obvious solution is to remove the RESULT_CACHE from the function declaration where it was erroneously placed to begin with?
Worst case scenario, you remove that and the application works slower ... but correctly. I don't see how that's problematic.
Cheers, -
Select first and last records in grouped results - Oracle 11g
Say I have the following information in an Oracle 11g table:
Qty
Production order
Date and time
20
00000000000000001
12-JAN-14 00:02
20
00000000000000001
12-JAN-14 00:05
20
00000000000000001
12-JAN-14 00:07
20
00000000000000001
13-JAN-14 00:09
30
00000000000000002
12-JAN-14 00:11
30
00000000000000002
12-JAN-14 00:15
30
00000000000000002
12-JAN-14 00:20
30
00000000000000002
14-JAN-14 00:29
I would like to write a query that would return the following:
Qty
Production order
First
Last
80
00000000000000001
12-JAN-14 00:02
13-JAN-14 00:09
120
00000000000000002
12-JAN-14 00:11
14-JAN-14 00:29
That is, the sum of the Qty column grouped by Production order, and the date/time of the first and last records for each Production order.
I came up with a query that yielded this result:
Qty
Production order
First
Last
80
00000000000000001
12-JAN-14 00:02
14-JAN-14 00:29
120
00000000000000002
12-JAN-14 00:02
14-JAN-14 00:29
Which means that the First and Last columns show the overall first and last date / time of the whole table. Please note that this is a dummy table. Sorry I am now allowed to write the actual query
I came up with since work policies do not allow me to share it. Also, I tried with windowing functions such as rank()and row_number() but my user does not have enough privileges to do so.
Any help or hints will be greatly appreciated.Due to the fact that Oracle does not record the rows in any particular order, it would be wrong that the "first date" would be the first row processed by the query.
Therefore you would have to supply some other column if you do not want to consider the table as ordered by date.
Also, any analytical functions will need you to supply the "order by" and if its the date, then just a simple query will do:
SQL>WITH Tab1 (Qty, Production_Order, Pdate)
2 AS (SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:02', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
3 SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:05', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
4 SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:07', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
5 SELECT 20, '00000000000000001', TO_DATE ( '13-JAN-14 00:09', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
6 SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:11', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
7 SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:15', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
8 SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:20', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
9 SELECT 30, '00000000000000002', TO_DATE ( '14-JAN-14 00:29', 'DD-MON-YY HH24:MI') FROM DUAL)
10 SELECT SUM ( Qty), Production_Order, MIN ( Pdate), MAX ( Pdate)
11 FROM Tab1
12 GROUP BY Production_Order
13* ORDER BY Production_Order
SQL> /
SUM(QTY) PRODUCTION_ORDER MIN(PDATE) MAX(PDATE)
80 00000000000000001 12-Jan-2014 00:02:00 13-Jan-2014 00:09:00
120 00000000000000002 12-Jan-2014 00:11:00 14-Jan-2014 00:29:00 -
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. -
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. -
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,
PiotrA 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
-
Hi, i had some animal photos that i added to photo stream and at the buttom of the folder it says "shared by me"... i want to see those photos on my apple tv, there is also a folder in photo stream named "my photo stream". i can only see "MY PHOTO ST
-
Acrobat 9.3.4 is very slow to open files
Greetings: I have Acrobat 9.3.4 installed on a Dell Latitude D630 with a 2.4 GHz T7700 Core 2 Duo processor and 4GB of RAM. I re-installed Windows XP SP3 about a month ago due to some USB issues. The motherboard was replaced prior to that to try to r
-
ITunes 10.6.3 on mac keep crashing
I am running iTunes 10.6.3 on my MacBookPro and it keeps crashing. I have also installed iPhoto 11. And still no luck.
-
How do change the settings in my music to hear more bass
how do I change settings in my music so I can hear more bass???
-
REG:table fields of purchase goods
hi, i need field like received quantity of material from vendor, rejected quantity of material from vendor, purchase order value,balance quantity of material from vendor. pls send me the details.. thanks to all