Pickler fetch
Actually my requirement is to have a view that accepts input parameter. As that is not possible, I decided to write a function that accepts those input parameters and fectches the rows into a Nested table declared in a package and returns that nested table. Now, I am using the function in my select statement as follows,
Select <columns> from table1,(Select column_value colval from table(cast(myfunction(:a) as mypackage.mytabletype)) ) dynamictable ;
I generated the explain plan command for the above query and found oracle using the PICKLER FETCH operation for fetching the value from my nested table.
My question is what is PICKLER FETCH? How it works? How efficient it is? Is there any drawback in this method?
Can anyone help me in this regard?
null
Shall I expect a reply from oracle technical team?
Similar Messages
-
COLLECTION ITERATOR PICKLER FETCH along with XMLSEQUENCEFROMXMLTYPE
Hi All,
We have Oracle database 10.2.0.4 on solaris 10.
I found some xml queries which are consuming CPU and memory highly, below is the execution plan for one of this xml sql.
PLAN_TABLE_OUTPUT
SQL_ID gzsfqp1mkfk8t, child number 0
SELECT B.PACKET_ID FROM CM_PACKET_ALT_KEY B, CM_ALT_KEY_TYPE C, TABLE (XMLSEQUENCE (EXTRACT (:B1 ,
'/AlternateKeys/AlternateKey'))) T WHERE B.ALT_KEY_TYPE_ID = C.ALT_KEY_TYPE_ID AND C.ALT_KEY_TYPE_NAME = EXTRACTVALUE
(VALUE (T), '/AlternateKey/@keyType') AND B.ALT_KEY_VALUE = EXTRACTVALUE (VALUE (T), '/AlternateKey') AND NVL
(B.CHILD_BROKER_CODE, '6209870F57C254D6E04400306E4A78B0') = NVL (EXTRACTVALUE (VALUE (T), '/AlternateKey/@broker'),
'6209870F57C254D6E04400306E4A78B0')
Plan hash value: 855909818
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | | | 16864 (100)| | | |
|* 1 | HASH JOIN | | 45 | 3240 | 16864 (2)| 00:03:23 | | |
| 2 | TABLE ACCESS FULL | CM_ALT_KEY_TYPE | 5 | 130 | 6 (0)| 00:00:01 | | |
|* 3 | HASH JOIN | | 227 | 10442 | 16858 (2)| 00:03:23 | | |
| 4 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | | | |
| 5 | PARTITION HASH ALL | | 10M| 447M| 16758 (2)| 00:03:22 | 1 | 16 |
| 6 | TABLE ACCESS FULL | CM_PACKET_ALT_KEY | 10M| 447M| 16758 (2)| 00:03:22 | 1 | 16 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
1 - access("B"."ALT_KEY_TYPE_ID"="C"."ALT_KEY_TYPE_ID" AND
"C"."ALT_KEY_TYPE_NAME"=SYS_OP_C2C(EXTRACTVALUE(VALUE(KOKBF$),'/AlternateKey/@keyType')))
3 - access("B"."ALT_KEY_VALUE"=EXTRACTVALUE(VALUE(KOKBF$),'/AlternateKey') AND
NVL("B"."CHILD_BROKER_CODE",'6209870F57C254D6E04400306E4A78B0')=NVL(EXTRACTVALUE(VALUE(KOKBF$),'/AlternateKey/@broker'
),'6209870F57C254D6E04400306E4A78B0'))Seems due to
1.COLLECTION ITERATOR PICKLER FETCH along with XMLSEQUENCEFROMXMLTYPE which i think is due to usage of table( XMLSEQUENCE() )
2.Conversion taking place according to SYS_OP_C2C function as shown in Predicate Information.
3.Table is not using xmltype datatype to store XML
4.Wilcards have been used (/AlternateKey/@keyType)
Could anyone please help me in tuning this query as i know very less about XML DB
Including one more sql which also use to consume huge CPU and memory, these tables are also not hving any column with xmltype datatype.
SELECT /*+ INDEX(e) */ XMLAGG(XMLELEMENT ( "TaggingCategory", XMLATTRIBUTES (G.TAG_CATEGORY_CODE AS
"categoryType"), XMLELEMENT ("TaggingValue", XMLATTRIBUTES (C.IS_PRIMARY AS "primary", H.ORIGIN_CODE AS
"origin"), XMLAGG (XMLCONCAT (XMLELEMENT ("Value", XMLATTRIBUTES (F.TAG_LIST_CODE AS "listType"),
E.TAG_VALUE), CASE WHEN LEVEL = 1 THEN :B4 ELSE NULL END))) )) FROM TABLE (CAST (:B1 AS
T_TAG_MAP_HIERARCHY_TAB)) A, TABLE (CAST (:B2 AS T_ENUM_TAG_TAB)) C, REM_TAG_VALUE E, REM_TAG_LIST F,
REM_TAG_CATEGORY G, CM_ORIGIN H WHERE E.TAG_VALUE_ID = C.TAG_VALUE_ID AND F.TAG_LIST_ID = E.TAG_LIST_ID
AND G.TAGGING_CATEGORY_ID = F.TAGGING_CATEGORY_ID AND H.ORIGIN_ID = C.ORIGIN_ID AND C.ENUM_TAG_ID =
A.MAPPED_ENUM_TAG_ID GROUP BY G.TAG_CATEGORY_CODE, C.IS_PRIMARY, H.ORIGIN_CODE START WITH
A.MAPPED_ENUM_TAG_ID = HEXTORAW (:B3 ) CONNECT BY PRIOR A.MAPPED_ENUM_TAG_ID = A.ENUM_TAG_ID
Plan hash value: 2393257319
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 16455 (100)| |
| 1 | SORT AGGREGATE | | 1 | 185 | 16455 (1)| 00:03:18 |
| 2 | SORT GROUP BY | | 1 | 185 | 16455 (1)| 00:03:18 |
|* 3 | CONNECT BY WITH FILTERING | | | | | |
|* 4 | FILTER | | | | | |
| 5 | COUNT | | | | | |
|* 6 | HASH JOIN | | 667K| 117M| 16413 (1)| 00:03:17 |
| 7 | COLLECTION ITERATOR PICKLER FETCH | | | | | |
|* 8 | HASH JOIN | | 8168 | 1459K| 16384 (1)| 00:03:17 |
| 9 | TABLE ACCESS FULL | REM_TAG_CATEGORY | 25 | 950 | 5 (0)| 00:00:01 |
|* 10 | HASH JOIN | | 8168 | 1156K| 16378 (1)| 00:03:17 |
| 11 | TABLE ACCESS FULL | REM_TAG_LIST | 117 | 7137 | 5 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 8168 | 670K| 16373 (1)| 00:03:17 |
| 13 | MERGE JOIN | | 8168 | 215K| 27 (4)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID | CM_ORIGIN | 2 | 50 | 2 (0)| 00:00:01 |
| 15 | INDEX FULL SCAN | PK_CM_ORIGIN | 2 | | 1 (0)| 00:00:01 |
|* 16 | SORT JOIN | | 8168 | 16336 | 25 (4)| 00:00:01 |
| 17 | COLLECTION ITERATOR PICKLER FETCH| | | | | |
| 18 | TABLE ACCESS BY INDEX ROWID | REM_TAG_VALUE | 1 | 57 | 2 (0)| 00:00:01 |
|* 19 | INDEX UNIQUE SCAN | PK_REM_TAG_VALUE | 1 | | 1 (0)| 00:00:01 |
|* 20 | HASH JOIN | | | | | |
| 21 | CONNECT BY PUMP | | | | | |
| 22 | COUNT | | | | | |
|* 23 | HASH JOIN | | 667K| 117M| 16413 (1)| 00:03:17 |
| 24 | COLLECTION ITERATOR PICKLER FETCH | | | | | |
|* 25 | HASH JOIN | | 8168 | 1459K| 16384 (1)| 00:03:17 |
| 26 | TABLE ACCESS FULL | REM_TAG_CATEGORY | 25 | 950 | 5 (0)| 00:00:01 |
|* 27 | HASH JOIN | | 8168 | 1156K| 16378 (1)| 00:03:17 |
| 28 | TABLE ACCESS FULL | REM_TAG_LIST | 117 | 7137 | 5 (0)| 00:00:01 |
| 29 | NESTED LOOPS | | 8168 | 670K| 16373 (1)| 00:03:17 |
| 30 | MERGE JOIN | | 8168 | 215K| 27 (4)| 00:00:01 |
| 31 | TABLE ACCESS BY INDEX ROWID | CM_ORIGIN | 2 | 50 | 2 (0)| 00:00:01 |
| 32 | INDEX FULL SCAN | PK_CM_ORIGIN | 2 | | 1 (0)| 00:00:01 |
|* 33 | SORT JOIN | | 8168 | 16336 | 25 (4)| 00:00:01 |
| 34 | COLLECTION ITERATOR PICKLER FETCH| | | | | |
| 35 | TABLE ACCESS BY INDEX ROWID | REM_TAG_VALUE | 1 | 57 | 2 (0)| 00:00:01 |
|* 36 | INDEX UNIQUE SCAN | PK_REM_TAG_VALUE | 1 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=PRIOR NULL)
4 - filter(SYS_OP_ATG(VALUE(KOKBF$),2,3,2)=HEXTORAW(:B3))
6 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),2,3,2))
8 - access("G"."TAGGING_CATEGORY_ID"="F"."TAGGING_CATEGORY_ID")
10 - access("F"."TAG_LIST_ID"="E"."TAG_LIST_ID")
16 - access("H"."ORIGIN_ID"=SYS_OP_ATG(VALUE(KOKBF$),3,4,2))
filter("H"."ORIGIN_ID"=SYS_OP_ATG(VALUE(KOKBF$),3,4,2))
19 - access("E"."TAG_VALUE_ID"=SYS_OP_ATG(VALUE(KOKBF$),7,8,2))
20 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=PRIOR NULL)
23 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),2,3,2))
25 - access("G"."TAGGING_CATEGORY_ID"="F"."TAGGING_CATEGORY_ID")
27 - access("F"."TAG_LIST_ID"="E"."TAG_LIST_ID")
33 - access("H"."ORIGIN_ID"=SYS_OP_ATG(VALUE(KOKBF$),3,4,2))
filter("H"."ORIGIN_ID"=SYS_OP_ATG(VALUE(KOKBF$),3,4,2))
36 - access("E"."TAG_VALUE_ID"=SYS_OP_ATG(VALUE(KOKBF$),7,8,2))-Yasser
Edited by: YasserRACDBA on Feb 24, 2010 8:30 PM
Added one more sql..Looking at the second query, it too has a lot of bind variables... Can you find out the types and values of each BIND. Also, I'm suspcious about the use of XMLCONCAT.. Can you found out why the developer is using it..
SELECT /*+ INDEX(e) */ XMLAGG
XMLELEMENT
"TaggingCategory",
XMLATTRIBUTES (G.TAG_CATEGORY_CODE AS "categoryType"),
XMLELEMENT
"TaggingValue",
XMLATTRIBUTES (C.IS_PRIMARY AS "primary", H.ORIGIN_CODE AS "origin"),
XMLAGG
XMLCONCAT
XMLELEMENT
"Value",
XMLATTRIBUTES (F.TAG_LIST_CODE AS "listType"),
E.TAG_VALUE
CASE WHEN LEVEL = 1
THEN :B4
ELSE NULL
END
FROM TABLE (CAST (:B1 AS T_TAG_MAP_HIERARCHY_TAB)) A,
TABLE (CAST (:B2 AS T_ENUM_TAG_TAB)) C,
REM_TAG_VALUE E,
REM_TAG_LIST F,
REM_TAG_CATEGORY G,
CM_ORIGIN H
WHERE E.TAG_VALUE_ID = C.TAG_VALUE_ID
AND F.TAG_LIST_ID = E.TAG_LIST_ID
AND G.TAGGING_CATEGORY_ID = F.TAGGING_CATEGORY_ID
AND H.ORIGIN_ID = C.ORIGIN_ID
AND C.ENUM_TAG_ID = A.MAPPED_ENUM_TAG_ID
GROUP BY G.TAG_CATEGORY_CODE, C.IS_PRIMARY, H.ORIGIN_CODE
START WITH A.MAPPED_ENUM_TAG_ID = HEXTORAW (:B3 )
CONNECT BY PRIOR A.MAPPED_ENUM_TAG_ID = A.ENUM_TAG_IDEdited by: mdrake on Feb 24, 2010 8:11 AM -
Does any one know how to wrap a view in Oracle, I know it is not possible, yet. Are there any third party software to wrap the logic in the view.
Thanks,
SanjayYour best bet is to write a view that queries the source tables and contains any necessary business logic
CREATE VIEW VBASE AS SELECT A.COLUMN_A FROM TABLE_1 A, TABLE_2 B, TABLE_3 C WHERE A.ID = B.ID AND B.ID = C.ID;
create a view for exposure to the user that queries the base view.
CREATE VIEW VSECURE AS SELECT COLUMN_B FROM VBASE;
and grant privileges to VSECURE.
GRANT SELECT ON VSECURE TO SECURE_USER;
This will allow the user to see, query, and describe VSECURE without seeing the definition for VBASE.
The advantage of the this approach is that the query engine can still push predicates down into the base view to optimize the performance or the query where as this is limited with the pipeline function and can become a tuning headache.
eg.
SQL> -----------------------------------------
SQL> -- create some tables
SQL> -----------------------------------------
SQL> CREATE TABLE table_1(ID NUMBER, MESSAGE VARCHAR2(100))
Table created.
SQL> CREATE TABLE table_2(ID NUMBER, message2 VARCHAR2(100))
Table created.
SQL> CREATE TABLE table_3(ID NUMBER, message3 VARCHAR2(100))
Table created.
SQL> -----------------------------------------
SQL> -- populate tables with some data
SQL> -----------------------------------------
SQL> INSERT INTO table_1
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'HELLO there joe'
ELSE 'goodbye joe'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> INSERT INTO table_2
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'how are you joe'
ELSE 'good to see you joe'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> INSERT INTO table_3
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'just some data'
ELSE 'other stuff'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> -----------------------------------------
SQL> --create base view
SQL> -----------------------------------------
SQL> CREATE OR REPLACE VIEW vbase AS
SELECT a.MESSAGE,
c.message3
FROM table_1 a,
table_2 b,
table_3 c
WHERE a.ID = b.ID
AND b.ID = c.ID
View created.
SQL> -----------------------------------------
SQL> --create secure view using base view
SQL> -----------------------------------------
SQL> CREATE OR REPLACE VIEW vsecure AS
SELECT MESSAGE,
message3
FROM vbase
View created.
SQL> -----------------------------------------
SQL> -- create row type for pipeline function
SQL> -----------------------------------------
SQL> CREATE OR REPLACE TYPE vbase_row
AS OBJECT
message varchar2(100),
message3 varchar2(100)
Type created.
SQL> -----------------------------------------
SQL> -- create table type for pipeline function
SQL> -----------------------------------------
SQL> CREATE OR REPLACE TYPE vbase_table
AS TABLE OF vbase_row;
Type created.
SQL> -----------------------------------------
SQL> -- create package
SQL> -----------------------------------------
SQL> CREATE OR REPLACE PACKAGE pkg_getdata AS
FUNCTION f_get_vbase
RETURN vbase_table PIPELINED;
END;
Package created.
SQL> -----------------------------------------
SQL> -- create package body with pipeline function using same query as vbase
SQL> -----------------------------------------
SQL> CREATE OR REPLACE PACKAGE BODY pkg_getdata AS
FUNCTION f_get_vbase
RETURN vbase_table PIPELINED IS
CURSOR cur IS
SELECT a.MESSAGE,
c.message3
FROM table_1 a,
table_2 b,
table_3 c
WHERE a.ID = b.ID
AND b.ID = c.ID;
BEGIN
FOR rec IN cur
LOOP
PIPE ROW ( vbase_row ( rec.MESSAGE, rec.message3 ) );
END LOOP;
END;
END pkg_getdata;
Package body created.
SQL> -----------------------------------------
SQL> -- create secure view using pipeline function
SQL> -----------------------------------------
SQL> CREATE or replace VIEW vsecure_with_pipe AS
SELECT *
FROM TABLE ( pkg_getdata.f_get_vbase ( ) )
View created.
SQL> -----------------------------------------
SQL> -- this would grant select on the 2 views, one with nested view, one with nested pipeline function
SQL> -----------------------------------------
SQL> GRANT SELECT ON vsecure TO test_user
Grant complete.
SQL> GRANT SELECT ON vsecure_with_pipe TO test_user
Grant complete.
SQL> explain plan for
SELECT *
FROM vsecure
WHERE MESSAGE LIKE 'HELLO%'
Explain complete.
SQL> SELECT *
FROM TABLE ( DBMS_XPLAN.display ( ) )
PLAN_TABLE_OUTPUT
Plan hash value: 3905984671
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 16939 | 2365K| | 3098 (3)| 00:00:54 |
|* 1 | HASH JOIN | | 16939 | 2365K| 2120K| 3098 (3)| 00:00:54 |
|* 2 | HASH JOIN | | 24103 | 1835K| | 993 (5)| 00:00:18 |
|* 3 | TABLE ACCESS FULL| TABLE_1 | 24102 | 1529K| | 426 (5)| 00:00:08 |
| 4 | TABLE ACCESS FULL| TABLE_2 | 1175K| 14M| | 559 (3)| 00:00:10 |
| 5 | TABLE ACCESS FULL | TABLE_3 | 826K| 51M| | 415 (3)| 00:00:08 |
Predicate Information (identified by operation id):
1 - access("B"."ID"="C"."ID")
2 - access("A"."ID"="B"."ID")
3 - filter("A"."MESSAGE" LIKE 'HELLO%')
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement
23 rows selected.
SQL> -----------------------------------------
SQL> -- note that the explain plan shows the predicate pushed down into the base view.
SQL> -----------------------------------------
SQL> explain plan for
SELECT count(*)
FROM vsecure_with_pipe
WHERE MESSAGE LIKE 'HELLO%'
Explain complete.
SQL> SELECT *
FROM TABLE ( DBMS_XPLAN.display ( ) )
PLAN_TABLE_OUTPUT
Plan hash value: 19045890
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 15 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
|* 2 | COLLECTION ITERATOR PICKLER FETCH| F_GET_VBASE | | | | |
Predicate Information (identified by operation id):
2 - filter(VALUE(KOKBF$) LIKE 'HELLO%')
14 rows selected.
SQL> -----------------------------------------
SQL> -- note that the filter is applied on the results of the pipeline function
SQL> -----------------------------------------
SQL> set timing on
SQL> SELECT count(*)
FROM vsecure
WHERE MESSAGE LIKE 'HELLO%'
COUNT(*)
19999
1 row selected.
Elapsed: 00:00:01.42
SQL> SELECT count(*)
FROM vsecure_with_pipe
WHERE MESSAGE LIKE 'HELLO%'
COUNT(*)
19999
1 row selected.
Elapsed: 00:00:04.11
SQL> -----------------------------------------
SQL> -- note the difference in the execution times.
SQL> ----------------------------------------- -
What is the benifit of Pipe function
Hi,
I agree that piping function return some set of rows when it is ready.
But if my main query where clause is using the piping function for filter like below
select p_name a1, p_add a2 from tname, tadd where tname.id = tadd.id and tname in (select * from table(pipe_fun_return_some_names));
Now my question is "using pipe function will my main query starts executing without waiting all data return by pipe function"
If yes then how my main query gets executed.
If No how can then will it cost me performance point of view.
so shell using piping function like this improve performance of my sql.
or simply can i use a table type and object to query ---
select p_name a1, p_add a2 from tname, tadd where tname.id = tadd.id and tname in (select * from table(table_fun_return_some_names));
Thanks Gurus...Ora_Is_Not_Magic wrote:
Hi,
I agree that piping function return some set of rows when it is ready.
But if my main query where clause is using the piping function for filter like below
select p_name a1, p_add a2 from tname, tadd where tname.id = tadd.id and tname in (select * from table(pipe_fun_return_some_names));
Now my question is "using pipe function will my main query starts executing without waiting all data return by pipe function"
If yes then how my main query gets executed.
If No how can then will it cost me performance point of view.Do you mean something along the lines that, if the value is found in the subquery (pipeline function) results early on it will return the main query data quicker than if the value is found later on in the subquery (pipeline function) results?
SQL> create or replace type t_nums as table of number;
2 /
Type created.
SQL> ed
Wrote file afiedt.buf
1 create or replace function f_pipe_asc return t_nums pipelined as
2 begin
3 for i in 1..1000000
4 loop
5 pipe row(i);
6 end loop;
7 return;
8* end;
SQL> /
Function created.
SQL> ed
Wrote file afiedt.buf
1 create or replace function f_pipe_desc return t_nums pipelined as
2 begin
3 for i in 1..1000000
4 loop
5 pipe row(1000001-i);
6 end loop;
7 return;
8* end;
SQL> /
Function created.
SQL> @c:\statson
SQL> select 1 from dual where 1 in (select * from table(f_pipe_asc()));
1
1
Elapsed: 00:00:00.29
Execution Plan
Plan hash value: 4199234228
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 82 | | 28 (8)| 00:00:01 |
| 1 | NESTED LOOPS | | 82 | | 28 (8)| 00:00:01 |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 3 | VIEW | VW_NSO_1 | 82 | | 26 (8)| 00:00:01 |
| 4 | SORT UNIQUE | | 82 | 164 | 26 (8)| 00:00:01 |
|* 5 | COLLECTION ITERATOR PICKLER FETCH| F_PIPE_ASC | | | | |
Predicate Information (identified by operation id):
5 - filter(VALUE(KOKBF$)=1)
Statistics
100 recursive calls
0 db block gets
88 consistent gets
0 physical reads
116 redo size
404 bytes sent via SQL*Net to client
396 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select 1 from dual where 1 in (select * from table(f_pipe_desc()));
1
1
Elapsed: 00:00:00.31
Execution Plan
Plan hash value: 2978834354
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 82 | | 28 (8)| 00:00:01 |
| 1 | NESTED LOOPS | | 82 | | 28 (8)| 00:00:01 |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 3 | VIEW | VW_NSO_1 | 82 | | 26 (8)| 00:00:01 |
| 4 | SORT UNIQUE | | 82 | 164 | 26 (8)| 00:00:01 |
|* 5 | COLLECTION ITERATOR PICKLER FETCH| F_PIPE_DESC | | | | |
Predicate Information (identified by operation id):
5 - filter(VALUE(KOKBF$)=1)
Statistics
28 recursive calls
0 db block gets
48 consistent gets
0 physical reads
0 redo size
404 bytes sent via SQL*Net to client
396 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>I don't have your data to test, but I'm guessing the fact the optimiser is doing a SORT UNIQUE on the pipeline results in order to perform the "IN", it's going to take the same amount of time whether the required value is the first out of the pipeline results or the last. -
Convrtd to Invterval Part- ORA-03113: end-of-file on communication channel
Hi all,
I had a table as Interval Partitioned. In order to create XML- Xpath indexes on it, I converted it to Range Partitioned table.
I am able to create the XPATH indexes but I get the error: ORA-03113: end-of-file on communication channel
- When I revert the code to Interval Partitioned without the XMLIndex, it works fine(although takes time as no XML Index)
- When I convert table to non partitioned table, create the XML Index, it works fine.
But I need the partitons, so when I create the partitioned table I get the error.
CREATE TABLE INT_PART_TABLE
DB_ID VARCHAR2(10 BYTE),
xML_mESSAGE SYS.XMLTYPE,
LOAD_TIMESTAMP TIMESTAMP(6)
XMLTYPE xML_mESSAGE STORE AS BINARY XML
PARTITION BY RANGE (LOAD_TIMESTAMP)
PARTITION MAX VALUES LESS THAN (TIMESTAMP' 2013-06-01 00:00:00')
TABLESPACE CSTR_STG_DATA
NOCOMPRESS
NOCACHE
ENABLE ROW MOVEMENT;
BEGIN
DBMS_XMLINDEX.dropparameter('Indx_Par');
END;
BEGIN
DBMS_XMLINDEX.REGISTERPARAMETER(
'Indx_Par',
'PATH TABLE Table1
PATHS (INCLUDE ( /abc:field1/xyz:field2
/abc:field1/def:field2
NAMESPACE MAPPING ( xmlns:abc="ABCD"
xmlns:def="DEFG"
xmlns:xyz="XYZA"
end;
create index INDX_XPATHS on "INT_PART_TABLE" (XML_MESSAGE) indextype is xdb.xmlindex
parameters ('PARAM Indx_Par') local;
Now if I execute the following statement in
SELECT T.xML_mESSAGE
FROM INT_PART_TABLE1 T
WHERE XMLEXISTS (
declare namespace abc="ABCD";
declare namespacedef="DEFG";
declare namespace xyz="XYZA";
let $tt as xs:boolean := fn:exists($p/main/id = ("144283","9085802")])
return if ($tt) then true()
else ()'
PASSING T.xML_mESSAGE AS "p");
- Is there any other way of writing this Select statement, which may work?
- Any other thing I need to take care of when defining the table and partitions script so that I don't get this error?Hi,
I think it's time you give a clear (and working) test case so that we can safely try to reproduce the issue.
What you've given so far has syntax error and name mismatch.
So please :
- database version (SELECT * FROM v$version)
- complete sequence of DLLs
- some sample XML documents (it doesn't have to be the real ones, but at least something realistic)
Thanks in advance.
declare namespace abc="ABCD";
declare namespacedef="DEFG";
declare namespace xyz="XYZA";
let $tt as xs:boolean := fn:exists($p/main/id = ("144283","9085802")])
return if ($tt) then true()
else ()'Why all that stuff? You don't have to return a boolean.
The following works for me on 11.2.0.3 :
SQL> CREATE TABLE int_part_table (
2 db_id VARCHAR2(10)
3 , xml_message XMLTYPE
4 , load_timestamp TIMESTAMP
5 )
6 XMLTYPE xml_message STORE AS BINARY XML
7 PARTITION BY RANGE (load_timestamp) (
8 PARTITION MAX VALUES LESS THAN (timestamp '2013-06-01 00:00:00')
9 )
10 NOCOMPRESS
11 NOCACHE
12 ENABLE ROW MOVEMENT;
Table created
SQL> insert into int_part_table values (1, xmltype('<main><id>144283</id></main>'), sysdate);
1 row inserted
SQL> insert into int_part_table values (1, xmltype('<main><id>9085802</id></main>'), sysdate);
1 row inserted
SQL> insert into int_part_table values (1, xmltype('<main><id>1</id></main>'), sysdate);
1 row inserted
SQL> commit;
Commit complete
SQL> create index int_part_table_uix on int_part_table (xml_message)
2 indextype is xdb.xmlindex
3 parameters (
4 'PATH TABLE INT_PART_TABLE_PT
5 PATHS ( INCLUDE ( /main/id ) )')
6 local;
Index created
SQL> SELECT xml_message
2 FROM int_part_table
3 WHERE XMLExists(
4 '/main[id=("144283","9085802")]'
5 PASSING xml_message
6 )
7 ;
XML_MESSAGE
<main>
<id>144283</id>
</main>
<main>
<id>9085802</id>
</main>
Execution Plan
Plan hash value: 3517234298
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 155 | 34 (6)| 00:00:01 | | |
| 1 | NESTED LOOPS | | 1 | 155 | 34 (6)| 00:00:01 | | |
| 2 | VIEW | VW_SQ_1 | 1 | 25 | 32 (4)| 00:00:01 | | |
| 3 | HASH UNIQUE | | 1 | 47 | | | | |
|* 4 | HASH JOIN SEMI | | 1 | 47 | 32 (4)| 00:00:01 | | |
| 5 | PARTITION SYSTEM SINGLE | | 2 | 90 | 2 (0)| 00:00:01 | 1 | 1 |
|* 6 | TABLE ACCESS BY LOCAL INDEX ROWID| INT_PART_TABLE_PT | 2 | 90 | 2 (0)| 00:00:01 | 1 | 1 |
|* 7 | INDEX SKIP SCAN | SYS117585_INT_PART__PIKEY_IX | 3 | | 1 (0)| 00:00:01 | 1 | 1 |
| 8 | COLLECTION ITERATOR PICKLER FETCH | XQSEQUENCEFROMXMLTYPE | 8168 | 16336 | 29 (0)| 00:00:01 | | |
|* 9 | TABLE ACCESS BY USER ROWID | INT_PART_TABLE | 1 | 130 | 1 (0)| 00:00:01 | ROWID | ROWID |
Predicate Information (identified by operation id):
4 - access("SYS_P3"."VALUE"=SYS_XQ_UPKXML2SQL(VALUE(KOKBF$),2,1,0) AND
SUBSTRB("VALUE",1,1599)=SUBSTRB(SYS_XQ_UPKXML2SQL(VALUE(KOKBF$),2,1,0),1,1599))
6 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
7 - access("SYS_P3"."PATHID"=HEXTORAW('704E') )
filter("SYS_P3"."PATHID"=HEXTORAW('704E') )
9 - filter("ITEM_6"=TBL$OR$IDX$PART$NUM("DEV"."INT_PART_TABLE",0,7,65535,"INT_PART_TABLE".ROWID))
Note
- Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)
SQL> SELECT xml_message
2 FROM int_part_table
3 WHERE XMLExists(
4 '/main[id="144283" or id="9085802"]'
5 PASSING xml_message
6 )
7 ;
XML_MESSAGE
<main>
<id>144283</id>
</main>
<main>
<id>9085802</id>
</main>
Execution Plan
Plan hash value: 3748936130
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 155 | 11 (10)| 00:00:01 | | |
| 1 | NESTED LOOPS | | 1 | 155 | 11 (10)| 00:00:01 | | |
| 2 | VIEW | VW_SQ_1 | 2 | 50 | 8 (0)| 00:00:01 | | |
| 3 | HASH UNIQUE | | 2 | 180 | | | | |
| 4 | CONCATENATION | | | | | | | |
| 5 | NESTED LOOPS | | | | | | | |
| 6 | NESTED LOOPS | | 1 | 90 | 4 (0)| 00:00:01 | | |
| 7 | PARTITION SYSTEM SINGLE | | 1 | 45 | 2 (0)| 00:00:01 | 1 | 1 |
|* 8 | TABLE ACCESS BY LOCAL INDEX ROWID| INT_PART_TABLE_PT | 1 | 45 | 2 (0)| 00:00:01 | 1 | 1 |
|* 9 | INDEX SKIP SCAN | SYS117585_INT_PART__PIKEY_IX | 3 | | 1 (0)| 00:00:01 | 1 | 1 |
| 10 | PARTITION SYSTEM SINGLE | | 1 | | 1 (0)| 00:00:01 | 1 | 1 |
|* 11 | INDEX RANGE SCAN | SYS117585_INT_PART__PIKEY_IX | 1 | | 1 (0)| 00:00:01 | 1 | 1 |
|* 12 | TABLE ACCESS BY LOCAL INDEX ROWID | INT_PART_TABLE_PT | 1 | 45 | 2 (0)| 00:00:01 | 1 | 1 |
| 13 | NESTED LOOPS | | | | | | | |
| 14 | NESTED LOOPS | | 1 | 90 | 4 (0)| 00:00:01 | | |
| 15 | PARTITION SYSTEM SINGLE | | 1 | 45 | 2 (0)| 00:00:01 | 1 | 1 |
|* 16 | TABLE ACCESS BY LOCAL INDEX ROWID| INT_PART_TABLE_PT | 1 | 45 | 2 (0)| 00:00:01 | 1 | 1 |
|* 17 | INDEX SKIP SCAN | SYS117585_INT_PART__PIKEY_IX | 3 | | 1 (0)| 00:00:01 | 1 | 1 |
| 18 | PARTITION SYSTEM SINGLE | | 1 | | 1 (0)| 00:00:01 | 1 | 1 |
|* 19 | INDEX RANGE SCAN | SYS117585_INT_PART__PIKEY_IX | 1 | | 1 (0)| 00:00:01 | 1 | 1 |
|* 20 | TABLE ACCESS BY LOCAL INDEX ROWID | INT_PART_TABLE_PT | 1 | 45 | 2 (0)| 00:00:01 | 1 | 1 |
|* 21 | TABLE ACCESS BY USER ROWID | INT_PART_TABLE | 1 | 130 | 1 (0)| 00:00:01 | ROWID | ROWID |
Predicate Information (identified by operation id):
8 - filter("SYS_P5"."VALUE"='9085802' AND SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1 AND SUBSTRB("VALUE",1,1599)='9085802')
9 - access("SYS_P5"."PATHID"=HEXTORAW('704E') )
filter("SYS_P5"."PATHID"=HEXTORAW('704E') )
11 - access("SYS_P5"."RID"="SYS_P3"."RID" AND "SYS_P3"."PATHID"=HEXTORAW('0BBD') AND
"SYS_P3"."ORDER_KEY"<"SYS_P5"."ORDER_KEY")
filter(SYS_ORDERKEY_DEPTH("SYS_P3"."ORDER_KEY")+1=SYS_ORDERKEY_DEPTH("SYS_P5"."ORDER_KEY") AND
TBL$OR$IDX$PART$NUM("DEV"."INT_PART_TABLE",0,7,65535,"SYS_P3"."RID")=TBL$OR$IDX$PART$NUM("DEV"."INT_PART_TABLE_PT",0,7,65535,ROWI
D) AND "SYS_P5"."ORDER_KEY"<SYS_ORDERKEY_MAXCHILD("SYS_P3"."ORDER_KEY"))
12 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
16 - filter("SYS_P5"."VALUE"='144283' AND SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1 AND SUBSTRB("VALUE",1,1599)='144283' AND
(LNNVL("SYS_P5"."VALUE"='9085802') OR LNNVL("SYS_P5"."PATHID"=HEXTORAW('704E') ) OR
LNNVL(SYS_XMLI_LOC_ISNODE("SYS_P5"."LOCATOR")=1) OR LNNVL(SUBSTRB("VALUE",1,1599)='9085802')))
17 - access("SYS_P5"."PATHID"=HEXTORAW('704E') )
filter("SYS_P5"."PATHID"=HEXTORAW('704E') )
19 - access("SYS_P5"."RID"="SYS_P3"."RID" AND "SYS_P3"."PATHID"=HEXTORAW('0BBD') AND
"SYS_P3"."ORDER_KEY"<"SYS_P5"."ORDER_KEY")
filter(SYS_ORDERKEY_DEPTH("SYS_P3"."ORDER_KEY")+1=SYS_ORDERKEY_DEPTH("SYS_P5"."ORDER_KEY") AND
TBL$OR$IDX$PART$NUM("DEV"."INT_PART_TABLE",0,7,65535,"SYS_P3"."RID")=TBL$OR$IDX$PART$NUM("DEV"."INT_PART_TABLE_PT",0,7,65535,ROWI
D) AND "SYS_P5"."ORDER_KEY"<SYS_ORDERKEY_MAXCHILD("SYS_P3"."ORDER_KEY"))
20 - filter(SYS_XMLI_LOC_ISNODE("SYS_P3"."LOCATOR")=1)
21 - filter("ITEM_2"=TBL$OR$IDX$PART$NUM("DEV"."INT_PART_TABLE",0,7,65535,"INT_PART_TABLE".ROWID))I asked in one of your other threads if /main/id was unique per XML document.
If so, you can use a simple function-based index instead of the XMLIndex :
SQL> drop index int_part_table_uix;
Index dropped.
SQL> create index int_part_table_ix1 on int_part_table (
2 xmlcast(
3 xmlquery('/main/id' passing XML_MESSAGE returning content)
4 as varchar2(10)
5 )
6 );
Index created.
SQL> SELECT xml_message
2 FROM int_part_table
3 WHERE XMLCast(
4 XMLQuery('/main/id' PASSING xml_message RETURNING CONTENT)
5 AS VARCHAR2(10)
6 )
7 IN ('144283', '9085802');
XML_MESSAGE
<main>
<id>144283</id>
</main>
<main>
<id>9085802</id>
</main>
Execution Plan
Plan hash value: 2864653096
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 2 | 236 | 2 (0)| 00:00:01 | | |
| 1 | INLIST ITERATOR | | | | | | | |
| 2 | TABLE ACCESS BY GLOBAL INDEX ROWID| INT_PART_TABLE | 2 | 236 | 2 (0)| 00:00:01 | 1 | 1 |
|* 3 | INDEX RANGE SCAN | INT_PART_TABLE_IX1 | 2 | | 1 (0)| 00:00:01 | | |
Predicate Information (identified by operation id):
3 - access(CAST(EXTRACTVALUE(SYS_MAKEXML(0,"SYS_NC00003$"),'/main/id',null,0,0,524293,1073874944) AS
varchar2(10) )='144283' OR CAST(EXTRACTVALUE(SYS_MAKEXML(0,"SYS_NC00003$"),'/main/id',null,0,0,524293,1073874944
) AS varchar2(10) )='9085802') -
Need Help in Breaking a big view into multiple small views or tuning the vw
Hi
I have the following view can some one help me in breaking the view in small views or any recommendations for tuning it.
CODE
CREATE OR REPLACE FORCE VIEW "CRUVPD"."PX16_CHK_VW_SUMMARY_VW" ("CIDN", "BATCH_NUMBER", "BUSINESS_UNIT", "CHECK_VOUCHER_NUMBER", "CHECK_VOUCHER_CODE", "CHECKVIEW_CLOCK_NUMBER", "COMPANY_CHECKVIEW_HOME_DEPT", "PERIOD_END_DATE", "FEDERAL_TAX", "GROSS_PAY"
, "HOME_DEPARTMENT", "HOME_DEPARTMENT_DESC", "LIVED_LOCAL_TAX_CODE", "LIVED_STATE_TAX_CODE", "LIVED_LOCAL_TAX", "LIVED_STATE_TAX", "MEDICARE_TAX", "NET_PAY", "DEPARTMENT_WORKED_IN", "PAY_TO_COMPANY_INDICATOR", "PAY_DATE", "PAYROLL_NUMBER", "SCHOOL_DISTRIC
T_TAX", "CHECKVIEW_SCHOOL_DISTRICT", "SOCIAL_SECURITY_TAX", "SUI_SDI_TAX", "SUI_SDI_TAX_CODE", "VOID_CHECK_INDICATOR", "WEEK_NUMBER", "WORKED_LOCAL_TAX_CODE", "WORKED_STATE_TAX_CODE", "WORKED_LOCAL_TAX", "WORKED_STATE_TAX", "YEAR", "COMPANY_CODE", "FILE_N
UMBER", "FIRST_NAME", "LAST_NAME", "LAST_NAME_FIRST_NAME", "SOCIAL_SECURITY_NUMBER", "STATUS", "OVERTIME_EARNINGS", "OVERTIME_HOURS", "REGULAR_EARNINGS", "REGULAR_HOURS", "VIEWPK", "HOME_COST_NUMBER", "TAX_FREQUENCY", "COMPANY_COST_NUMBER", "COST_NUMBER_W
ORKED_IN", "DISTRIBUTION_NUMBER", "TOTAL_DEDUCTIONS_AMOUNT", "TOTAL_HOURS_AMOUNT", "TOTAL_MEMO_AMOUNT", "TOTAL_OTHER_EARNINGS", "TOTAL_OTHER_HOURS", "CHECK_SEQ_NO", "JOINKEY", "CHECK_REVERSAL_INDICATOR") AS
with user_security_homedept
AS
(select /*+ INLINE */ distinct cg.cidn,co_code,asso.oid,asso.name,department_Access ,t2.column_value dep,cg.oid
from px16_cocodegroup cg ,
px16_associate asso ,
px16_securityobject so,
px16_cocodegrp_securitygrp cs,
px16_security_group sg ,
TABLE(f_str2tbl_px16(cg.department_access)) t2
where cg.USEROID = asso.OID
and cg.co_code = substr(so.name,8,3)
and upper(asso.name) = upper(sys_context('payx_r16_app_context', 'app_userid'))
and cg.oid = cs.cocodegroupoid
and cs.securitygroupoid = sg.oid
and cg.cidn = asso.cidn
and cg.cidn = so.cidn
and cg.cidn = cs.cidn
and cs.cidn = sg.cidn
order by 2,1
user_security_cost_no
AS
(select /*+ INLINE */
cg.cidn,co_code,count(distinct cd.code)cost_no,cd.code
from px16_cocodegroup cg ,
px16_associate asso ,
px16_securityobject so,
px16_cocodegrp_securitygrp cs,
px16_security_group sg ,
px16_customaccessdetail cd
where cg.USEROID = asso.OID
and cg.co_code = substr(so.name,8,3)
and upper(asso.name) = upper(sys_context('payx_r16_app_context', 'app_userid'))
and cg.oid = cs.cocodegroupoid
and cs.securitygroupoid = sg.oid
and cg.oid = cd.cocodegroupoid(+)
and cg.cidn = cd.cidn(+)
and cg.cidn = asso.cidn
and cg.cidn = so.cidn
and cg.cidn = cs.cidn
and cs.cidn = sg.cidn
group by cg.cidn,co_code,cd.code
order by 2,1
super_user_check as
(SELECT
distinct a.cidn su_cidn,1 as su_user
FROM
px16_LINK LN
, px16_userprofile up
, px16_ASSOCIATE a
, px16_pcp_user pu
WHERE
a.oid = pu.oid
AND pu.userprofileoid = up.oid
AND LN.parentoid = up.oid
AND a.active = 1
AND a.cidn=pu.cidn
AND pu.cidn=up.cidn
AND ln.cidn=up.cidn
AND upper(a.name) = upper(sys_context('payx_r16_app_context', 'app_userid'))
AND upper(up.name) = upper('Super user')
nonsuper_user_check as
SELECT distinct a.cidn s_cidn , 1 as non_user
FROM
px16_LINK LN
, px16_userprofile up
, px16_ASSOCIATE a
, px16_pcp_user pu
WHERE
a.oid = pu.oid
AND pu.userprofileoid = up.oid
AND LN.parentoid = up.oid
AND a.active = 1
AND a.cidn=pu.cidn
AND pu.cidn=up.cidn
AND ln.cidn=up.cidn
AND upper(a.name) = upper(sys_context('payx_r16_app_context', 'app_userid'))
AND LN.childoid IN ( 'SYS:5:7478')
SELECT distinct
cidn
,batch_number Batch_Number
, business_unit Business_Unit
, check_voucher_number Check_Voucher_Number
, check_voucher_code Check_Voucher_Code
, clock_number CheckView_Clock_Number
, company_code_or_dept Company_CheckView_Home_Dept
, period_end_date Period_End_Date
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, 1, (INSTR(taxes_and_rates, '~', 1, 1) -1)), CHR(155), NULL)) Federal_Tax
, gross_pay Gross_Pay
, home_department Home_Department
, home_department_descr Home_Department_Desc
, SUBSTR(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 1) +1)
, INSTR(taxes_and_rates, '~', 1, 2) - (INSTR(taxes_and_rates, '~', 1, 1) +1)), CHR(155), NULL), 1, 32) Lived_Local_Tax_Code
, SUBSTR(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 2) +1)
, INSTR(taxes_and_rates, '~', 1, 3) - (INSTR(taxes_and_rates, '~', 1, 2) +1)), CHR(155), NULL), 1, 32) Lived_State_Tax_Code
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 3) +1)
, INSTR(taxes_and_rates, '~', 1, 4) - (INSTR(taxes_and_rates, '~', 1, 3) +1)), CHR(155), NULL)) Lived_Local_Tax
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 4) +1)
, INSTR(taxes_and_rates, '~', 1, 5) - (INSTR(taxes_and_rates, '~', 1, 4) +1)), CHR(155), NULL)) Lived_State_Tax
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 5) +1)
, INSTR(taxes_and_rates, '~', 1, 6) - (INSTR(taxes_and_rates, '~', 1, 5) +1)), CHR(155), NULL)) Medicare_Tax
, net_pay Net_Pay
, department_paid Department_Worked_In
, to_pay_indicator Pay_to_Company_Indicator
, pay_date Pay_Date
, payroll_number Payroll_Number
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 6) +1)
, INSTR(taxes_and_rates, '~', 1, 7) - (INSTR(taxes_and_rates, '~', 1, 6) +1)), CHR(155), NULL)) School_District_Tax
, SUBSTR(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 7) +1)
, INSTR(taxes_and_rates, '~', 1, 8) - (INSTR(taxes_and_rates, '~', 1, 7) +1)), CHR(155), NULL), 1, 32) CheckView_School_District
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 8) +1)
, INSTR(taxes_and_rates, '~', 1, 9) - (INSTR(taxes_and_rates, '~', 1, 8) +1)), CHR(155), NULL)) Social_Security_Tax
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 9) +1)
, INSTR(taxes_and_rates, '~', 1, 10) - (INSTR(taxes_and_rates, '~', 1, 9) +1)), CHR(155), NULL)) SUI_SDI_Tax
, SUBSTR(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 10) +1)
, INSTR(taxes_and_rates, '~', 1, 11) - (INSTR(taxes_and_rates, '~', 1, 10) +1)), CHR(155), NULL), 1, 32) SUI_SDI_Tax_Code
, void_check_indicator Void_Check_Indicator
, week_number Week_Number
, SUBSTR(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 11) +1)
, INSTR(taxes_and_rates, '~', 1, 12) - (INSTR(taxes_and_rates, '~', 1, 11) +1)), CHR(155), NULL), 1, 32) Worked_Local_Tax_Code
, SUBSTR(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 12) +1)
, INSTR(taxes_and_rates, '~', 1, 13) - (INSTR(taxes_and_rates, '~', 1, 12) +1)), CHR(155), NULL), 1, 32) Worked_State_Tax_Code
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 13) +1)
, INSTR(taxes_and_rates, '~', 1, 14) - (INSTR(taxes_and_rates, '~', 1, 13) +1)), CHR(155), NULL)) Worked_Local_Tax
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 14) +1)
, INSTR(taxes_and_rates, '~', 1, 15) - (INSTR(taxes_and_rates, '~', 1, 14) +1)), CHR(155), NULL)) Worked_State_Tax
, year Year
, company_code Company_Code
, file_number File_Number
, first_name First_Name
, last_name Last_Name
, name Last_Name_First_Name
, ssn Social_Security_Number
, status Status
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 15) +1)
, INSTR(taxes_and_rates, '~', 1, 16) - (INSTR(taxes_and_rates, '~', 1, 15) +1)), CHR(155), NULL)) Overtime_Earnings
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 16) +1)
, INSTR(taxes_and_rates, '~', 1, 17) - (INSTR(taxes_and_rates, '~', 1, 16) +1)), CHR(155), NULL)) Overtime_Hours
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 17) +1)
, INSTR(taxes_and_rates, '~', 1, 18) - (INSTR(taxes_and_rates, '~', 1, 17) +1)), CHR(155), NULL)) Regular_Earnings
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 18) +1)
, INSTR(taxes_and_rates, '~', 1, 19) - (INSTR(taxes_and_rates, '~', 1, 18) +1)), CHR(155), NULL)) Regular_Hours
, (company_code || '/' || ssn || '/' || file_number || '/' || TO_CHAR(payroll_number) || '/'
|| TO_CHAR(year) || '/' || TO_CHAR(week_number) || '/' || check_voucher_number
|| '/' || to_char(check_seq_num) || '/' || TO_CHAR(distribution_number)) Viewpk
, home_costnumber_desc Home_Cost_Number
, tax_frequency Tax_Frequency
, co_chkv_home_cost_no Company_Cost_Number
, cost_no_worked_in Cost_Number_Worked_In
, distribution_number Distribution_Number
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 19) +1)
, INSTR(taxes_and_rates, '~', 1, 20) - (INSTR(taxes_and_rates, '~', 1, 19) +1)), CHR(155), NULL)) Total_Deductions_Amount
, NVL(TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 20) +1)
, INSTR(taxes_and_rates, '~', 1, 21) - (INSTR(taxes_and_rates, '~', 1, 20) +1)), CHR(155), NULL)), 0) Total_Hours_Amount
, NVL(TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 21) +1)
, INSTR(taxes_and_rates, '~', 1, 22) - (INSTR(taxes_and_rates, '~', 1, 21) +1)), CHR(155), NULL)), 0) Total_Memo_Amount
, NVL(TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 22) +1)
, INSTR(taxes_and_rates, '~', 1, 23) - (INSTR(taxes_and_rates, '~', 1, 22) +1)), CHR(155), NULL)), 0) Total_Other_Earnings
, TO_NUMBER(REPLACE(SUBSTR(taxes_and_rates, (INSTR(taxes_and_rates, '~', 1, 23) +1)), CHR(155), NULL)) Total_Other_Hours
, check_seq_num Check_Seq_No
, (NVL(company_code, '~') || CHR(155) || NVL(file_number, '~') || CHR(155) || NVL(ssn, '~') || CHR(155) || NVL(TO_CHAR(year), '~') || CHR(155)
|| NVL(TO_CHAR(week_number), '~') || CHR(155) || NVL(TO_CHAR(payroll_number), '~')
|| CHR(155) || NVL(check_voucher_number, '~') || CHR(155) || NVL(TO_CHAR(check_seq_num), '~') || CHR(155) || NVL(TO_CHAR(distribution_number), '~')) Joinkey
, chk_reverse Check_Reversal_Indicator
FROM
SELECT
ch.cidn cidn
/*BATCH NUMBER*/
, ch.batch_nb batch_number
, /*BUSINESS UNIT*/
(select asso.description
from px16_appointment ap,
px16_jobposition jp,
px16_corporation co,
px16_associate asso,
px16_payrollagreement pa,
px16_payrollgroup pg
where
ch.cidn = pg.cidn
AND ch.cidn = pa.cidn
AND pa.cidn = pg.cidn
AND pa.cidn = ap.cidn
AND em.cidn = ap.cidn
AND ap.cidn = jp.cidn
and jp.cidn = co.cidn
and co.cidn = asso.cidn
and ch.co_code=pg.co_code
and ch.file_nb=pa.file_number
and pa.cocodeoid=pg.oid
and pa.appointmentoid=ap.oid
and em.oid=ap.employmentoid
and ap.jobpositionoid=jp.oid
and jp.corporationoid=co.oid
and co.oid=asso.oid) business_unit
, /*CHECK/VOUCHER NUMBER*/
ch.check_nb check_voucher_number
, /*CHECK/VOUCHER CODE*/
SUBSTR(f_type_px16(ch.cidn,ch.chkvchcodeoid, 'NAME'), 1, 255) check_voucher_code
, /*CLOCK NUMBER*/
ch.clock_id clock_number
, /* COMPANY CODE OR DEPT*/
ch.co_code||'/'||substr(ch.home_dept_code,1,20) company_code_or_dept
, /*PERIOD END DATE*/
ch.payroll_ending_date period_end_date
, /*GROSS PAY*/
NVL(chd.gross_pay_amt,0) gross_pay
, /*HOME DEPARTMENT*/
ch.home_dept_code home_department
, /*HOME DEPARTMENT DESCRIPTION*/
(select ty.description
from px16_type ty,px16_securityobject sc
where
ch.cidn = sc.cidn
and ty.cidn in ('COMMON', ch.cidn)
and ch.home_dept_code=ty.name
and ty.category='T_CO_DEPT'
and ty.securityoid=sc.oid
and ch.co_code=substr(sc.name,8)) home_department_descr
, /*NET PAY*/
nvl(chd.net_pay_amt,0) net_pay
, /*DEPARTMENT PAID*/
-- ch.paid_in_debt_code department_paid
chd.worked_in_dept department_paid
, /*TO PAY INDICATOR*/
decode(to_char(ch.pay_to_co),'1','Y','0','N',to_char(ch.pay_to_co)) to_pay_indicator
, /*PAY DATE*/
ch.pay_date pay_date
, /*PAYROLL NUMBER*/
to_char(ch.payroll_nb) payroll_number
, /*VOID CHECK INDICATOR*/
decode(to_char(ch.void_flag),'1','Y','0','N',to_char(ch.void_flag)) void_check_indicator
, /*WEEK NUMBER*/
TO_number(ch.week) week_number
, /*YEAR*/
to_char(ch.year) year
, /*COMPANY CODE*/
ch.co_code company_code
, /*FILE NUMBER*/
LPAD(ch.file_nb,6,0) file_number
, /*FIRST NAME*/
pe.first_name first_name
, /*LAST NAME*/
pe.last_name last_name
, /*NAME*/
pe.last_name||', '||pe.first_name name
, /*SSN*/
payx_r16_principal_info.masked_ssn(pe.unique_id, ch.cidn) ssn
, /*STATUS*/
(SELECT SUBSTR(f_type_px16(ap.cidn,ap.currentstatusoid, 'DESC'), 1, 255)
from
px16_appointment ap,
/*context co_ap,*/
px16_payrollagreement pa,
px16_payrollgroup pg
where
pg.cidn=ch.cidn
and pa.cidn=ch.cidn
and ap.cidn=pa.cidn
and ap.cidn = em.cidn
and ap.employmentoid=em.oid
and ap.active=1
and ap.oid=pa.appointmentoid
and lpad(to_char(pa.file_number),6,0)=ch.file_nb
and pa.cocodeoid=pg.oid
and pg.co_code=ch.co_code) status
-- FED TAX
-- , LIVED LOCAL TAX CODE, LIVED STATE TAX CODE, LIVED LOCAL TAX, LIVED STATE TAX, MEDICARE TAX
-- , SCHOOL DISTRICT TAX, SCHOOL DISTRICT, SOCIAL SECURITY TAX, SUI SDI TAX, SUI SDI TAX CODE
-- , WORKED LOCAL TAX CODE, WORKED STATE TAX CODE, WORKED LOCAL TAX, WORKED STATE TAX
-- , OVERTIME EARNINGS, OVERTIME HOURS, REGULAR EARNINGS, REGULAR HOURS
NVL (
(SELECT
TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2982', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| NVL(MAX(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2984', ci.code, NULL), NULL)), CHR(155)) || '~'
|| NVL(MAX(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2987', DECODE(ci.code,'XX',null,ci.code), NULL), NULL)), CHR(155)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2984', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2987', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:4118', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:4114', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| NVL(MAX(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:4114', ci.code, NULL), NULL)), CHR(155)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2988', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2989', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| NVL(MAX(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2989', ci.code, NULL), NULL)), CHR(155)) || '~'
|| NVL(MAX(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2983', ci.code, NULL), NULL)), CHR(155)) || '~'
|| NVL(MAX(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2986', ci.code, NULL), NULL)), CHR(155)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2983', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3709', DECODE(ci.taxcodeoid, 'SYS:4:2986', NVL(ci.amount,0), 0), 0) ), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3713', NVL(ci.amount,0), 0)), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3727', NVL(ci.amount,0), 0)), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3715', NVL(ci.amount,0), 0)), 0)) || '~'
|| TO_CHAR(NVL(SUM(DECODE(ci.histtypeoid, 'SYS:4:3716', NVL(ci.amount,0), 0)), 0)) || '~'
-- R16 columns.
-- Total Deductions Amount === Other Deductions on UI screen.
|| TO_CHAR(NVL(SUM(DECODE(chcat.name, 'DeductionHistory'
, DECODE(NVL(ci.statutory_ded, 0), 0
, DECODE(ci.taxcodeoid, NULL
, DECODE(ci.code, NULL, 0, NVL(ci.amount,0)), 0), 0), 0)), 0)) || '~' -- "Total Deductions Amount"
|| TO_CHAR(NVL(SUM(DECODE(chcat.name, 'OvertimeHours', NVL(ci.amount,0)
, 'AdditionalHours', NVL(ci.amount,0), 'RegularHours', NVL(ci.amount,0), 0)), 0)) || '~' -- "Total Hours Amount"
|| TO_CHAR(NVL(SUM(DECODE(chcat.name, 'Memo', NVL(ci.amount,0), 0)), 0)) || '~' -- "Total Memo Amount"
|| TO_CHAR(NVL(SUM(DECODE(chcat.name, 'AdditionalEarnings', NVL(ci.amount,0), 0)), 0)) || '~' -- "Total Other Earnings"
|| TO_CHAR(NVL(SUM(DECODE(chcat.name, 'AdditionalHours', NVL(ci.amount,0), 0)), 0)) -- "Total Other Hours"
FROM
px16_checkhistoryitem ci
, px16_sys_type chcat
WHERE
ci.cidn=chd.cidn
AND ci.checkhistorydistributionoid = chd.oid
AND chcat.category = 'CheckHistoryItem'
AND chcat.oid = ci.histtypeoid
-- AND ci.histtypeoid IN ('SYS:4:3713', 'SYS:4:3727', 'SYS:4:3715', 'SYS:4:3716', 'SYS:4:3709')
), '0' || '~' || CHR(155) || '~' || CHR(155)
|| '0~0~0~0~' || CHR(155) || '~0~0~' || CHR(155) || '~' || CHR(155) || '~'
|| CHR(155) || '~0~0~0~0~0~0'
) taxes_and_rates
, ch.check_seq_num check_seq_num
, ch.home_cost_number home_costnumber_desc
, SUBSTR(f_type_px16(ch.cidn,ch.payfrequencyoid, 'NAME'), 1, 255) tax_frequency
, (ch.co_code || '/' || ch.home_cost_number) co_chkv_home_cost_no
, chd.worked_in_cost_number cost_no_worked_in
, chd.distribution_number distribution_number
, DECODE(NVL(ch.reversed_flag, 0), 1, 'Y', 'N') chk_reverse
FROM
px16_checkhistory ch
, px16_employment em
, px16_person pe
, px16_payrollgroup pg
, px16_checkhistory_dist chd
, px16_appointment ap
WHERE
ch.cidn = em.cidn
and em.cidn = pe.cidn
and pg.cidn = ch.cidn
and ch.cidn = chd.cidn
and ap.cidn(+) = em.cidn
and ch.employmentoid=em.oid
AND em.personoid=pe.oid
AND pg.co_code = ch.co_code
AND ch.active = 1
AND ch.oid = chd.checkhistoryoid
AND ap.employmentoid(+) = em.oid
AND DECODE(ap.oid, NULL, 1, NVL((SELECT 1 FROM px16_payrollagreement pa
WHERE
pa.cidn = ap.cidn
and pa.cidn = ch.cidn
and pa.cidn = pg.cidn
and pa.appointmentoid = ap.oid
AND pa.file_number = ch.file_nb
AND pa.cocodeoid = pg.oid), 0)) = 1
and ch.cidn in (select distinct s_cidn from nonsuper_user_check)
AND ( sys_context('payx_r16_app_context', 'app_role') in ('ADP', 'CSR')
or (exists (select 1 from super_user_check where su_cidn =ch.cidn))
or (ch.cidn,ch.co_code,ch.home_dept_code) in (select cidn,co_code,dep from user_security_homedept)
or (ch.cidn,ch.co_code,ch.home_cost_number) in (select cidn,co_code,code from user_security_cost_no)
or ( exists(select co_code from user_security_homedept where cidn=ch.cidn and co_code = ch.co_code and dep is null)
and exists(select co_code from user_security_cost_no where cidn=ch.cidn and co_code = ch.co_code and cost_no = 0) )
Explain plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 7519 | 99 (2)|
| 1 | VIEW | PX16_CHK_VW_SUMMARY_VW | 1 | 7519 | |
| 2 | SORT UNIQUE | | 1 | 445 | 78 (0)|
|* 3 | FILTER | | | | |
| 4 | NESTED LOOPS OUTER | | 1 | 445 | 63 (2)|
| 5 | NESTED LOOPS | | 1 | 414 | 58 (2)|
| 6 | NESTED LOOPS | | 1 | 362 | 53 (2)|
| 7 | NESTED LOOPS | | 1 | 331 | 48 (3)|
| 8 | NESTED LOOPS | | 1 | 306 | 43 (3)|
| 9 | NESTED LOOPS | | 1 | 253 | 38 (3)|
| 10 | NESTED LOOPS | | 1 | 120 | 23 (5)|
| 11 | NESTED LOOPS | | 1 | 79 | 18 (6)|
| 12 | NESTED LOOPS | | 1 | 53 | 13 (8)|
|* 13 | INDEX FAST FULL SCAN | USERPROFILE_GG_U | 5 | 110 | 11 (0)|
|* 14 | INDEX RANGE SCAN | UQ_LINK | 1 | 31 | |
| 15 | TABLE ACCESS BY INDEX ROWID | PCP_USER | 1 | 26 | 6 (17)|
|* 16 | INDEX RANGE SCAN | XIF3PCP_USER | 1 | | |
|* 17 | TABLE ACCESS BY INDEX ROWID | ASSOCIATE | 1 | 41 | 6 (17)|
|* 18 | INDEX UNIQUE SCAN | ASSOCIATE_GG_U | 1 | | |
|* 19 | TABLE ACCESS BY INDEX ROWID | CHECKHISTORY | 1 | 133 | 16 (7)|
|* 20 | INDEX RANGE SCAN | J_CO_CODE | 13 | | 2 (0)|
| 21 | TABLE ACCESS BY INDEX ROWID | CHECKHISTORYDISTRIBUTION | 1 | 53 | 6 (17)|
|* 22 | INDEX RANGE SCAN | TMP_IDX11 | 1 | | |
| 23 | TABLE ACCESS BY INDEX ROWID | PAYROLLGROUP | 1 | 25 | 6 (17)|
|* 24 | INDEX RANGE SCAN | PAYROLLGROUP_IDX2 | 1 | | |
| 25 | TABLE ACCESS BY INDEX ROWID | EMPLOYMENT | 1 | 31 | 6 (17)|
|* 26 | INDEX UNIQUE SCAN | EMPLOYMENT_GG_U | 1 | | |
| 27 | TABLE ACCESS BY INDEX ROWID | PERSON | 1 | 52 | 6 (17)|
|* 28 | INDEX UNIQUE SCAN | PERSON_GG_U | 1 | | |
| 29 | TABLE ACCESS BY INDEX ROWID | APPOINTMENT | 1 | 31 | 6 (17)|
|* 30 | INDEX RANGE SCAN | XIF12APPOINTMENT | 1 | | |
|* 31 | FILTER | | | | |
|* 32 | TABLE ACCESS BY INDEX ROWID | PAYROLLAGREEMENT | 1 | 34 | 21 (5)|
|* 33 | INDEX RANGE SCAN | UQ_FILE_NO_COCODE | 1 | | 3 (0)|
|* 34 | FILTER | | | | |
| 35 | NESTED LOOPS | | 1 | 130 | 27 (4)|
| 36 | NESTED LOOPS | | 1 | 89 | 22 (5)|
| 37 | NESTED LOOPS | | 1 | 63 | 17 (6)|
|* 38 | TABLE ACCESS BY INDEX ROWID | USERPROFILE | 1 | 41 | 16 (7)|
|* 39 | INDEX RANGE SCAN | XIF1USERPROFILE | 1 | | 2 (0)|
|* 40 | INDEX RANGE SCAN | LINK_IDX2 | 1 | 22 | |
| 41 | TABLE ACCESS BY INDEX ROWID | PCP_USER | 1 | 26 | 6 (17)|
|* 42 | INDEX RANGE SCAN | XIF3PCP_USER | 1 | | |
|* 43 | TABLE ACCESS BY INDEX ROWID | ASSOCIATE | 1 | 41 | 6 (17)|
|* 44 | INDEX UNIQUE SCAN | ASSOCIATE_GG_U | 1 | | |
|* 45 | FILTER | | | | |
| 46 | NESTED LOOPS | | 1 | 144 | 48 (3)|
| 47 | MERGE JOIN CARTESIAN | | 1 | 142 | 37 (3)|
| 48 | NESTED LOOPS | | 1 | 116 | 32 (4)|
| 49 | NESTED LOOPS | | 1 | 96 | 31 (4)|
| 50 | NESTED LOOPS | | 1 | 72 | 26 (4)|
|* 51 | TABLE ACCESS BY INDEX ROWID | COCODEGROUP | 1 | 34 | 21 (5)|
|* 52 | INDEX RANGE SCAN | XIF1COCODEGROUP | 9 | | 2 (0)|
|* 53 | TABLE ACCESS BY INDEX ROWID | ASSOCIATE | 1 | 38 | 6 (17)|
|* 54 | INDEX UNIQUE SCAN | ASSOCIATE_GG_U | 1 | | |
|* 55 | INDEX RANGE SCAN | COSEC_IDX_GG | 1 | 24 | 1 (0)|
|* 56 | INDEX UNIQUE SCAN | SECURITY_GROUP_GG_U | 1 | 20 | |
| 57 | BUFFER SORT | | 1 | 26 | 35 (0)|
|* 58 | INDEX RANGE SCAN | UQ_SECURITYOBJECT | 1 | 26 | 1 (0)|
|* 59 | COLLECTION ITERATOR PICKLER FETCH | F_STR2TBL_PX16 | | | |
|* 60 | FILTER | | | | |
| 61 | SORT GROUP BY | | 1 | 183 | 66 (0)|
| 62 | NESTED LOOPS | | 1 | 183 | 51 (2)|
| 63 | NESTED LOOPS | | 1 | 163 | 50 (2)|
|* 64 | HASH JOIN OUTER | | 1 | 139 | 45 (3)|
| 65 | NESTED LOOPS | | 1 | 96 | 42 (3)|
|* 66 | HASH JOIN | | 1 | 58 | 37 (3)|
| 67 | TABLE ACCESS BY INDEX ROWID | SECURITYOBJECT | 13 | 338 | 16 (7)|
|* 68 | INDEX RANGE SCAN | SECURITYOBJECT_IDX1 | 13 | | 2 (0)|
| 69 | TABLE ACCESS BY INDEX ROWID | COCODEGROUP | 9 | 288 | 21 (5)|
|* 70 | INDEX RANGE SCAN | XIF1COCODEGROUP | 1 | | 2 (0)|
|* 71 | TABLE ACCESS BY INDEX ROWID | ASSOCIATE | 1 | 38 | 6 (17)|
|* 72 | INDEX UNIQUE SCAN | ASSOCIATE_GG_U | 1 | | |
|* 73 | TABLE ACCESS FULL | CUSTOMACCESSDETAIL | 9 | 387 | 2 (0)|
|* 74 | INDEX RANGE SCAN | COSEC_IDX_GG | 1 | 24 | 1 (0)|
|* 75 | INDEX UNIQUE SCAN | SECURITY_GROUP_GG_U | 1 | 20 | |
| 76 | VIEW | | 1 | 2032 | |
| 77 | SORT UNIQUE | | 1 | 144 | 63 (0)|
|* 78 | FILTER | | | | |
| 79 | NESTED LOOPS | | 1 | 144 | 48 (3)|
| 80 | NESTED LOOPS | | 1 | 142 | 37 (3)|
| 81 | NESTED LOOPS | | 1 | 104 | 32 (4)|
| 82 | NESTED LOOPS | | 1 | 84 | 31 (4)|
| 83 | NESTED LOOPS | | 1 | 60 | 26 (4)|
|* 84 | TABLE ACCESS BY INDEX ROWID | COCODEGROUP | 1 | 34 | 21 (5)|
|* 85 | INDEX RANGE SCAN | XIF1COCODEGROUP | 9 | | 2 (0)|
|* 86 | INDEX RANGE SCAN | UQ_SECURITYOBJECT | 1 | 26 | 1 (0)|
|* 87 | INDEX RANGE SCAN | COSEC_IDX_GG | 1 | 24 | 1 (0)|
|* 88 | INDEX UNIQUE SCAN | SECURITY_GROUP_GG_U | 1 | 20 | |
|* 89 | TABLE ACCESS BY INDEX ROWID | ASSOCIATE | 1 | 38 | 6 (17)|
|* 90 | INDEX UNIQUE SCAN | ASSOCIATE_GG_U | 1 | | |
|* 91 | COLLECTION ITERATOR PICKLER FETCH| F_STR2TBL_PX16 | | | |
| 92 | VIEW | | 1 | 43 | |
|* 93 | FILTER | | | | |
| 94 | SORT GROUP BY | | 1 | 183 | 55 (0)|
|* 95 | FILTER | | | | |
| 96 | NESTED LOOPS | | 1 | 183 | 40 (3)|
| 97 | NESTED LOOPS | | 1 | 163 | 39 (3)|
|* 98 | HASH JOIN OUTER | | 1 | 139 | 34 (3)|
| 99 | NESTED LOOPS | | 1 | 96 | 31 (4)|
| 100 | NESTED LOOPS | | 1 | 58 | 26 (4)|
|*101 | TABLE ACCESS BY INDEX ROWID | COCODEGROUP | 1 | 32 | 21 (5)|
|*102 | INDEX RANGE SCAN | XIF1COCODEGROUP | 9 | | 2 (0)|
|*103 | INDEX RANGE SCAN | UQ_SECURITYOBJECT | 1 | 26 | 1 (0)|
|*104 | TABLE ACCESS BY INDEX ROWID | ASSOCIATE | 1 | 38 | 6 (17)|
|*105 | INDEX UNIQUE SCAN | ASSOCIATE_GG_U | 1 | | |
|*106 | TABLE ACCESS FULL | CUSTOMACCESSDETAIL | 9 | 387 | 2 (0)|
|*107 | INDEX RANGE SCAN | COSEC_IDX_GG | 1 | 24 | 1 (0)|
|*108 | INDEX UNIQUE SCAN | SECURITY_GROUP_GG_U | 1 | 20 | |
Predicate Information (identified by operation id):
3 - filter(DECODE("SYS_ALIAS_19"."OID",NULL,1,NVL( (SELECT /*+ */ 1 FROM "PAYX_R16"."PAYROLLAGREEMENT"
"PX16_PAYROLLAGREEMENT" WHERE :B1='C69C1Y' AND :B2=:B3 AND :B4=:B5 AND
"PX16_PAYROLLAGREEMENT"."FILE_NUMBER"=TO_NUMBER(:B6) AND "PX16_PAYROLLAGREEMENT"."COCODEOID"=:B7 AND
"PX16_PAYROLLAGREEMENT"."CIDN"=:B8 AND "PX16_PAYROLLAGREEMENT"."APPOINTMENTOID"=:B9),0))=1 AND
(SYS_CONTEXT('payx_r16_app_context','app_role')='ADP' OR
SYS_CONTEXT('payx_r16_app_context','app_role')='CSR' OR EXISTS (SELECT /*+ */ 0 FROM
"PAYX_R16"."PCP_USER" "PX16_PCP_USER","PAYX_R16"."ASSOCIATE" "PX16_ASSOCIATE","PAYX_R16"."USERPROFILE"
"PX16_USERPROFILE","PAYX_R16"."LINK" "PX16_LINK" WHERE :B10='C69C1Y' AND
"PX16_LINK"."PARENTOID"="PX16_USERPROFILE"."OID" AND "PX16_LINK"."CIDN"='C69C1Y' AND
"PX16_LINK"."CIDN"=:B11 AND "PX16_USERPROFILE"."CIDN"='C69C1Y' AND UPPER("PX16_USERPROFILE"."NAME")='SUPER
USER' AND "PX16_USERPROFILE"."CIDN"=:B12 AND "PX16_ASSOCIATE"."CIDN"=:B13 AND
"PX16_ASSOCIATE"."OID"="PX16_PCP_USER"."OID" AND "PX16_ASSOCIATE"."ACTIVE"=1 AND
UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')) AND
"PX16_PCP_USER"."USERPROFILEOID"="PX16_USERPROFILE"."OID" AND "PX16_PCP_USER"."CIDN"='C69C1Y' AND
"PX16_PCP_USER"."USERPROFILEOID" IS NOT NULL AND "PX16_PCP_USER"."CIDN"=:B14) OR EXISTS (SELECT /*+ */ 0
FROM TABLE("CRUVPD"."F_STR2TBL_PX16"("PX16_COCODEGROUP"."DEPARTMENT_ACCESS"))
"KOKBF$","PAYX_R16"."SECURITY_GROUP" "PX16_SECURITY_GROUP","PAYX_R16"."COCODEGROUP_SECURITYGROUP"
"PX16_COCODEGRP_SECURITYGRP","PAYX_R16"."SECURITYOBJECT" "PX16_SECURITYOBJECT","PAYX_R16"."ASSOCIATE"
"PX16_ASSOCIATE","PAYX_R16"."COCODEGROUP" "PX16_COCODEGROUP" WHERE :B15='C69C1Y' AND
"PX16_COCODEGROUP"."CIDN"=:B16 AND "PX16_COCODEGROUP"."CO_CODE"=:B17 AND "PX16_ASSOCIATE"."CIDN"='C69C1Y'
AND "PX16_COCODEGROUP"."USEROID"="PX16_ASSOCIATE"."OID" AND
UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')) AND
"PX16_ASSOCIATE"."CIDN"=:B18 AND "PX16_SECURITYOBJECT"."CIDN"='C69C1Y' AND
SUBSTR("PX16_SECURITYOBJECT"."NAME",8,3)=:B19 AND "PX16_SECURITYOBJECT"."CIDN"=:B20 AND
"PX16_COCODEGROUP"."OID"="PX16_COCODEGRP_SECURITYGRP"."COCODEGROUPOID" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"=:B21 AND "PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y' AND
"PX16_SECURITY_GROUP"."CIDN"='C69C1Y' AND "PX16_COCODEGRP_SECURITYGRP"."SECURITYGROUPOID"="PX16_SECURITY_GR
OUP"."OID" AND "PX16_SECURITY_GROUP"."CIDN"=:B22 AND VALUE(KOKBF$)=:B23) OR EXISTS (SELECT /*+ */ 0 FROM
"PAYX_R16"."CUSTOMACCESSDETAIL" "PX16_CUSTOMACCESSDETAIL","PAYX_R16"."SECURITY_GROUP"
"PX16_SECURITY_GROUP","PAYX_R16"."COCODEGROUP_SECURITYGROUP"
"PX16_COCODEGRP_SECURITYGRP","PAYX_R16"."SECURITYOBJECT" "PX16_SECURITYOBJECT","PAYX_R16"."ASSOCIATE"
"PX16_ASSOCIATE","PAYX_R16"."COCODEGROUP" "PX16_COCODEGROUP" WHERE "PX16_COCODEGROUP"."CIDN"='C69C1Y' AND
"PX16_COCODEGROUP"."CIDN"="PX16_SECURITYOBJECT"."CIDN" AND
"PX16_COCODEGROUP"."CO_CODE"=SUBSTR("PX16_SECURITYOBJECT"."NAME",8,3) AND "PX16_ASSOCIATE"."CIDN"='C69C1Y'
AND "PX16_COCODEGROUP"."USEROID"="PX16_ASSOCIATE"."OID" AND
UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')) AND
"PX16_COCODEGROUP"."CIDN"="PX16_ASSOCIATE"."CIDN" AND "PX16_SECURITYOBJECT"."CIDN"='C69C1Y' AND
"PX16_COCODEGROUP"."OID"="PX16_COCODEGRP_SECURITYGRP"."COCODEGROUPOID" AND
"PX16_COCODEGROUP"."CIDN"="PX16_COCODEGRP_SECURITYGRP"."CIDN" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y' AND "PX16_SECURITY_GROUP"."CIDN"='C69C1Y' AND
"PX16_COCODEGRP_SECURITYGRP"."SECURITYGROUPOID"="PX16_SECURITY_GROUP"."OID" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"="PX16_SECURITY_GROUP"."CIDN" AND
"PX16_COCODEGROUP"."CIDN"="PX16_CUSTOMACCESSDETAIL"."CIDN"(+) AND
"PX16_COCODEGROUP"."OID"="PX16_CUSTOMACCESSDETAIL"."COCODEGROUPOID"(+) AND
"PX16_CUSTOMACCESSDETAIL"."CIDN"(+)='C69C1Y' GROUP BY
"PX16_COCODEGROUP"."CIDN","PX16_COCODEGROUP"."CO_CODE","PX16_CUSTOMACCESSDETAIL"."CODE" HAVING
"PX16_COCODEGROUP"."CIDN"=:B24 AND "PX16_COCODEGROUP"."CO_CODE"=:B25 AN)
13 - filter("PX16_USERPROFILE"."CIDN"='C69C1Y')
14 - access("PX16_LINK"."CIDN"='C69C1Y' AND "PX16_LINK"."CHILDOID"='SYS:5:7478' AND
"PX16_LINK"."PARENTOID"="PX16_USERPROFILE"."OID")
filter("PX16_LINK"."CIDN"="PX16_USERPROFILE"."CIDN")
16 - access("PX16_PCP_USER"."CIDN"='C69C1Y' AND "PX16_PCP_USER"."USERPROFILEOID"="PX16_USERPROFILE"."OID"
filter("PX16_PCP_USER"."USERPROFILEOID" IS NOT NULL AND
"PX16_PCP_USER"."CIDN"="PX16_USERPROFILE"."CIDN")
17 - filter("PX16_ASSOCIATE"."ACTIVE"=1 AND UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_ap
p_context','app_userid')))
18 - access("PX16_ASSOCIATE"."OID"="PX16_PCP_USER"."OID" AND "PX16_ASSOCIATE"."CIDN"='C69C1Y')
filter("PX16_ASSOCIATE"."CIDN"="PX16_PCP_USER"."CIDN")
19 - filter("SYS_ALIAS_32"."ACTIVE"=1)
20 - access("SYS_ALIAS_32"."CIDN"='C69C1Y')
filter("SYS_ALIAS_32"."CIDN"="PX16_ASSOCIATE"."CIDN")
22 - access("SYS_ALIAS_15"."CIDN"='C69C1Y' AND "SYS_ALIAS_32"."OID"="SYS_ALIAS_15"."CHECKHISTORYOID")
filter("SYS_ALIAS_32"."CIDN"="SYS_ALIAS_15"."CIDN")
24 - access("SYS_ALIAS_21"."CIDN"='C69C1Y' AND "SYS_ALIAS_21"."CO_CODE"="SYS_ALIAS_32"."CO_CODE")
filter("SYS_ALIAS_21"."CIDN"="SYS_ALIAS_32"."CIDN")
26 - access("SYS_ALIAS_32"."EMPLOYMENTOID"="SYS_ALIAS_11"."OID" AND "SYS_ALIAS_11"."CIDN"='C69C1Y')
filter("SYS_ALIAS_32"."CIDN"="SYS_ALIAS_11"."CIDN")
28 - access("SYS_ALIAS_11"."PERSONOID"="PX16_PERSON"."OID" AND "PX16_PERSON"."CIDN"='C69C1Y')
filter("SYS_ALIAS_11"."CIDN"="PX16_PERSON"."CIDN")
30 - access("SYS_ALIAS_19"."CIDN"(+)='C69C1Y' AND "SYS_ALIAS_19"."EMPLOYMENTOID"(+)="SYS_ALIAS_11"."OID")
filter("SYS_ALIAS_19"."CIDN"(+)="SYS_ALIAS_11"."CIDN")
31 - filter(:B1='C69C1Y' AND :B2=:B3 AND :B4=:B5)
32 - filter("PX16_PAYROLLAGREEMENT"."APPOINTMENTOID"=:B1)
33 - access("PX16_PAYROLLAGREEMENT"."CIDN"=:B1 AND "PX16_PAYROLLAGREEMENT"."COCODEOID"=:B2 AND
"PX16_PAYROLLAGREEMENT"."FILE_NUMBER"=TO_NUMBER(:B3))
34 - filter(:B1='C69C1Y')
38 - filter(UPPER("PX16_USERPROFILE"."NAME")='SUPER USER')
39 - access("PX16_USERPROFILE"."CIDN"='C69C1Y')
filter("PX16_USERPROFILE"."CIDN"=:B1)
40 - access("PX16_LINK"."CIDN"='C69C1Y' AND "PX16_LINK"."PARENTOID"="PX16_USERPROFILE"."OID")
filter("PX16_LINK"."CIDN"=:B1)
42 - access("PX16_PCP_USER"."CIDN"='C69C1Y' AND "PX16_PCP_USER"."USERPROFILEOID"="PX16_USERPROFILE"."OID"
filter("PX16_PCP_USER"."USERPROFILEOID" IS NOT NULL AND "PX16_PCP_USER"."CIDN"=:B1)
43 - filter("PX16_ASSOCIATE"."ACTIVE"=1 AND UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_ap
p_context','app_userid')))
44 - access("PX16_ASSOCIATE"."OID"="PX16_PCP_USER"."OID" AND "PX16_ASSOCIATE"."CIDN"=:B1)
45 - filter(:B1='C69C1Y')
51 - filter("PX16_COCODEGROUP"."CO_CODE"=:B1)
52 - access("PX16_COCODEGROUP"."CIDN"=:B1)
53 - filter(UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')))
54 - access("PX16_COCODEGROUP"."USEROID"="PX16_ASSOCIATE"."OID" AND "PX16_ASSOCIATE"."CIDN"='C69C1Y')
filter("PX16_ASSOCIATE"."CIDN"=:B1)
55 - access("PX16_COCODEGROUP"."OID"="PX16_COCODEGRP_SECURITYGRP"."COCODEGROUPOID" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
filter("PX16_COCODEGRP_SECURITYGRP"."CIDN"=:B1 AND "PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
56 - access("PX16_COCODEGRP_SECURITYGRP"."SECURITYGROUPOID"="PX16_SECURITY_GROUP"."OID" AND
"PX16_SECURITY_GROUP"."CIDN"='C69C1Y')
filter("PX16_SECURITY_GROUP"."CIDN"=:B1)
58 - access("PX16_SECURITYOBJECT"."CIDN"='C69C1Y')
filter(SUBSTR("PX16_SECURITYOBJECT"."NAME",8,3)=:B1 AND "PX16_SECURITYOBJECT"."CIDN"=:B2)
59 - filter(VALUE(KOKBF$)=:B1)
60 - filter("PX16_COCODEGROUP"."CIDN"=:B1 AND "PX16_COCODEGROUP"."CO_CODE"=:B2 AND
"PX16_CUSTOMACCESSDETAIL"."CODE"=:B3)
64 - access("PX16_COCODEGROUP"."OID"="PX16_CUSTOMACCESSDETAIL"."COCODEGROUPOID"(+) AND
"PX16_COCODEGROUP"."CIDN"="PX16_CUSTOMACCESSDETAIL"."CIDN"(+))
66 - access("PX16_COCODEGROUP"."CO_CODE"=SUBSTR("PX16_SECURITYOBJECT"."NAME",8,3) AND
"PX16_COCODEGROUP"."CIDN"="PX16_SECURITYOBJECT"."CIDN")
68 - access("PX16_SECURITYOBJECT"."CIDN"='C69C1Y')
70 - access("PX16_COCODEGROUP"."CIDN"='C69C1Y')
71 - filter(UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')))
72 - access("PX16_COCODEGROUP"."USEROID"="PX16_ASSOCIATE"."OID" AND "PX16_ASSOCIATE"."CIDN"='C69C1Y')
filter("PX16_COCODEGROUP"."CIDN"="PX16_ASSOCIATE"."CIDN")
73 - filter("PX16_CUSTOMACCESSDETAIL"."CIDN"(+)='C69C1Y')
74 - access("PX16_COCODEGROUP"."OID"="PX16_COCODEGRP_SECURITYGRP"."COCODEGROUPOID" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
filter("PX16_COCODEGROUP"."CIDN"="PX16_COCODEGRP_SECURITYGRP"."CIDN" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
75 - access("PX16_COCODEGRP_SECURITYGRP"."SECURITYGROUPOID"="PX16_SECURITY_GROUP"."OID" AND
"PX16_SECURITY_GROUP"."CIDN"='C69C1Y')
filter("PX16_COCODEGRP_SECURITYGRP"."CIDN"="PX16_SECURITY_GROUP"."CIDN")
78 - filter('C69C1Y'=:B1)
84 - filter("PX16_COCODEGROUP"."CO_CODE"=:B1)
85 - access("PX16_COCODEGROUP"."CIDN"='C69C1Y')
86 - access("PX16_SECURITYOBJECT"."CIDN"='C69C1Y')
filter(SUBSTR("PX16_SECURITYOBJECT"."NAME",8,3)=:B1 AND
"PX16_COCODEGROUP"."CIDN"="PX16_SECURITYOBJECT"."CIDN")
87 - access("PX16_COCODEGROUP"."OID"="PX16_COCODEGRP_SECURITYGRP"."COCODEGROUPOID" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
filter("PX16_COCODEGROUP"."CIDN"="PX16_COCODEGRP_SECURITYGRP"."CIDN" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
88 - access("PX16_COCODEGRP_SECURITYGRP"."SECURITYGROUPOID"="PX16_SECURITY_GROUP"."OID" AND
"PX16_SECURITY_GROUP"."CIDN"='C69C1Y')
filter("PX16_COCODEGRP_SECURITYGRP"."CIDN"="PX16_SECURITY_GROUP"."CIDN")
89 - filter(UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')))
90 - access("PX16_COCODEGROUP"."USEROID"="PX16_ASSOCIATE"."OID" AND "PX16_ASSOCIATE"."CIDN"='C69C1Y')
filter("PX16_COCODEGROUP"."CIDN"="PX16_ASSOCIATE"."CIDN")
91 - filter(VALUE(KOKBF$) IS NULL)
93 - filter(COUNT(DISTINCT "PX16_CUSTOMACCESSDETAIL"."CODE")=0)
95 - filter('C69C1Y'=:B1)
98 - access("PX16_COCODEGROUP"."OID"="PX16_CUSTOMACCESSDETAIL"."COCODEGROUPOID"(+) AND
"PX16_COCODEGROUP"."CIDN"="PX16_CUSTOMACCESSDETAIL"."CIDN"(+))
101 - filter("PX16_COCODEGROUP"."CO_CODE"=:B1)
102 - access("PX16_COCODEGROUP"."CIDN"='C69C1Y')
103 - access("PX16_SECURITYOBJECT"."CIDN"='C69C1Y')
filter(SUBSTR("PX16_SECURITYOBJECT"."NAME",8,3)=:B1 AND
"PX16_COCODEGROUP"."CIDN"="PX16_SECURITYOBJECT"."CIDN")
104 - filter(UPPER("PX16_ASSOCIATE"."NAME")=UPPER(SYS_CONTEXT('payx_r16_app_context','app_userid')))
105 - access("PX16_COCODEGROUP"."USEROID"="PX16_ASSOCIATE"."OID" AND "PX16_ASSOCIATE"."CIDN"='C69C1Y')
filter("PX16_COCODEGROUP"."CIDN"="PX16_ASSOCIATE"."CIDN")
106 - filter("PX16_CUSTOMACCESSDETAIL"."CIDN"(+)='C69C1Y')
107 - access("PX16_COCODEGROUP"."OID"="PX16_COCODEGRP_SECURITYGRP"."COCODEGROUPOID" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
filter("PX16_COCODEGROUP"."CIDN"="PX16_COCODEGRP_SECURITYGRP"."CIDN" AND
"PX16_COCODEGRP_SECURITYGRP"."CIDN"='C69C1Y')
108 - access("PX16_COCODEGRP_SECURITYGRP"."SECURITYGROUPOID"="PX16_SECURITY_GROUP"."OID" AND
"PX16_SECURITY_GROUP"."CIDN"='C69C1Y')
filter("PX16_COCODEGRP_SECURITYGRP"."CIDN"="PX16_SECURITY_GROUP"."CIDN")
277 rows selected.
Really need advice on it.Without formatting using [ PRE ] and [ /PRE ] tags it is nearly impossible to read much less provide help.
But what is it you hope to accomplish by breaking it up into smaller views?
Improvements in ease of maintenance will likely be offset by poorer performance. -
How to retrieve values from Referring Nodes
Hi
My sample XML nodes are, assume these to nodes are in a same XML file.
<DestinationBandDefinitionList>
<DestinationBandDefinition>
<DestinationBandName>Group 1</DestinationBandName>
<DestinationList>
<Destination>
<Name>India</Name>
<DestinationIdentifierList type="prefix">
<Value>91</Value>
</DestinationIdentifierList>
</Destination>
<Destination>
<Name>USA</Name>
<DestinationIdentifierList type="prefix">
<Value>1</Value>
</DestinationIdentifierList>
</Destination>
</DestinationBandDefinition>
</DestinationBandDefinitionList>
<DestinationBandDefinitionList>
<DestinationBandDefinition>
<DestinationBandName>Group 2</DestinationBandName>
<DestinationList>
<Destination>
<Name>UAE</Name>
<DestinationIdentifierList type="prefix">
<Value>971</Value>
</DestinationIdentifierList>
</Destination>
<Destination>
<Name>Russia</Name>
<DestinationIdentifierList type="prefix">
<Value>7</Value>
</DestinationIdentifierList>
</Destination>
</DestinationBandDefinition>
</DestinationBandDefinitionList>
<TariffList>
<DestinationBand>
<DestinationBandName>Group 1</DestinationBandName>
<RatingIntervalName>standard1</RatingIntervalName>
<Rate taxIncluded="false" type="N">3.50</Rate>
</RateSpecification>
<RateSpecification>
<RatingIntervalName>standard2</RatingIntervalName>
<Rate taxIncluded="false" type="N">3.50</Rate>
</RateSpecification>
</RateSpecificationList>
</DestinationBand>
What is the statement to query the Taxincluded value of the Group, where USA belongs.
My DB is Oracle 10g 2.0.1.0
Thanks in advance
RizlySQL> with XML as
2 (
3 select XMLTYPE(
4 '<Root>
5 <DestinationBandDefinitionList>
6 <DestinationBandDefinition>
7 <DestinationBandName>Group 1</DestinationBandName>
8 <DestinationList>
9 <Destination>
10 <Name>India</Name>
11 <DestinationIdentifierList type="prefix">
12 <Value>91</Value>
13 </DestinationIdentifierList>
14 </Destination>
15 <Destination>
16 <Name>USA</Name>
17 <DestinationIdentifierList type="prefix">
18 <Value>1</Value>
19 </DestinationIdentifierList>
20 </Destination>
21 </DestinationList>
22 </DestinationBandDefinition>
23 </DestinationBandDefinitionList>
24 <DestinationBandDefinitionList>
25 <DestinationBandDefinition>
26 <DestinationBandName>Group 2</DestinationBandName>
27 <DestinationList>
28 <Destination>
29 <Name>UAE</Name>
30 <DestinationIdentifierList type="prefix">
31 <Value>971</Value>
32 </DestinationIdentifierList>
33 </Destination>
34 <Destination>
35 <Name>Russia</Name>
36 <DestinationIdentifierList type="prefix">
37 <Value>7</Value>
38 </DestinationIdentifierList>
39 </Destination>
40 </DestinationList>
41 </DestinationBandDefinition>
42 </DestinationBandDefinitionList>
43 <TariffList>
44 <DestinationBand>
45 <DestinationBandName>Group 1</DestinationBandName>
46 <RatingIntervalName>standard1</RatingIntervalName>
47 <Rate taxIncluded="false" type="N">3.50</Rate>
48 <RateSpecificationList>
49 <RateSpecification>
50 <RatingIntervalName>standard2</RatingIntervalName>
51 <Rate taxIncluded="false" type="N">3.50</Rate>
52 </RateSpecification>
53 </RateSpecificationList>
54 </DestinationBand>
55 </TariffList>
56 </Root>') XMLDOC
57 from dual
58 )
59 select xmlquery
60 (
61 '$doc/Root/TariffList/DestinationBand[DestinationBandName/text() = $doc/Root/DestinationBandDefinitionList/De
BandDefinition[DestinationList/Destination[Name="USA"]]/DestinationBandName/text()]/Rate/@taxIncluded'
62 passing XMLDOC as "doc" returning content
63 )
64 from XML;
false
Elapsed: 00:00:00.09
Execution Plan
Plan hash value: 2594004460
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
|* 2 | FILTER | | | | | |
| 3 | COLLECTION ITERATOR PICKLER FETCH | XMLSEQUENCEFROMXMLTYPE | | | | |
| 4 | NESTED LOOPS | | 667K| 2606K| 221K (1)| 00:44:24 |
| 5 | COLLECTION ITERATOR PICKLER FETCH| XQSEQUENCEFROMXMLTYPE | | | | |
|* 6 | COLLECTION ITERATOR PICKLER FETCH| XQSEQUENCEFROMXMLTYPE | | | | |
| 7 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter( EXISTS (SELECT 0 FROM TABLE() "KOKBF$",TABLE() "KOKBF$" WHERE
SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0)=SYS_XQ_UPKXML2SQL(SY
S_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0)))
6 - filter(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0)=SYS_XQ
_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0))
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> set heading on
SQL> with XML as
2 (
3 select XMLTYPE(
4 '<Root>
5 <DestinationBandDefinitionList>
6 <DestinationBandDefinition>
7 <DestinationBandName>Group 1</DestinationBandName>
8 <DestinationList>
9 <Destination>
10 <Name>India</Name>
11 <DestinationIdentifierList type="prefix">
12 <Value>91</Value>
13 </DestinationIdentifierList>
14 </Destination>
15 <Destination>
16 <Name>USA</Name>
17 <DestinationIdentifierList type="prefix">
18 <Value>1</Value>
19 </DestinationIdentifierList>
20 </Destination>
21 </DestinationList>
22 </DestinationBandDefinition>
23 </DestinationBandDefinitionList>
24 <DestinationBandDefinitionList>
25 <DestinationBandDefinition>
26 <DestinationBandName>Group 2</DestinationBandName>
27 <DestinationList>
28 <Destination>
29 <Name>UAE</Name>
30 <DestinationIdentifierList type="prefix">
31 <Value>971</Value>
32 </DestinationIdentifierList>
33 </Destination>
34 <Destination>
35 <Name>Russia</Name>
36 <DestinationIdentifierList type="prefix">
37 <Value>7</Value>
38 </DestinationIdentifierList>
39 </Destination>
40 </DestinationList>
41 </DestinationBandDefinition>
42 </DestinationBandDefinitionList>
43 <TariffList>
44 <DestinationBand>
45 <DestinationBandName>Group 1</DestinationBandName>
46 <RatingIntervalName>standard1</RatingIntervalName>
47 <Rate taxIncluded="false" type="N">3.50</Rate>
48 <RateSpecificationList>
49 <RateSpecification>
50 <RatingIntervalName>standard2</RatingIntervalName>
51 <Rate taxIncluded="false" type="N">3.50</Rate>
52 </RateSpecification>
53 </RateSpecificationList>
54 </DestinationBand>
55 </TariffList>
56 </Root>') XMLDOC
57 from dual
58 )
59 select xmlquery
60 (
61 '$doc/Root/TariffList/DestinationBand[DestinationBandName/text() = $doc/Root/DestinationBandDefinitionList/De
BandDefinition[DestinationList/Destination[Name="USA"]]/DestinationBandName/text()]/Rate/@taxIncluded'
62 passing XMLDOC as "doc" returning content
63 ) RESULT
64 from XML;
false
Elapsed: 00:00:00.10
Execution Plan
Plan hash value: 2594004460
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
|* 2 | FILTER | | | | | |
| 3 | COLLECTION ITERATOR PICKLER FETCH | XMLSEQUENCEFROMXMLTYPE | | | | |
| 4 | NESTED LOOPS | | 667K| 2606K| 221K (1)| 00:44:24 |
| 5 | COLLECTION ITERATOR PICKLER FETCH| XQSEQUENCEFROMXMLTYPE | | | | |
|* 6 | COLLECTION ITERATOR PICKLER FETCH| XQSEQUENCEFROMXMLTYPE | | | | |
| 7 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter( EXISTS (SELECT 0 FROM TABLE() "KOKBF$",TABLE() "KOKBF$" WHERE
SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0)=SYS_XQ_UPKXML2SQL(SY
S_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0)))
6 - filter(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0)=SYS_XQ
_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(VALUE(KOKBF$),'/text()'),1,50),50,1,0))
SQL>
SQL>
SQL>
SQL>
SQL> -
XMLQuery starts using XMLSEQUENCEFROMXMLTYPE when adding filter to query
Hi,
I'm creating a single XML view on 3 relational tables. These table represent:
1. a dataset description (table: refs)
2. a keyset (table: keyset, a table with between refs )
3. a data set (table: data, consisting of reference to key, value, and reference to a dataset)
Per dataset I can have multiple keys, per key I have multiple values
(1:N for dataset:keys, 1:N keys:values)
The definition is given below:
DROP TABLE data;
DROP TABLE refs;
DROP TABLE keyset;
CREATE TABLE data (ref int, key int, value float);
CREATE TABLE refs (ref int);
CREATE TABLE keyset (key int, ref int);
CREATE INDEX data_krv ON data (key,ref,value);
CREATE INDEX keyset_kr ON keyset (key,ref);
INSERT INTO refs VALUES (1);
INSERT INTO refs VALUES (2);
INSERT INTO data VALUES (1,1,1.5);
INSERT INTO data VALUES (1,1,2.5);
INSERT INTO data VALUES (1,2,3.5);
INSERT INTO data VALUES (1,2,4.5);
INSERT INTO data VALUES (2,1,5.5);
INSERT INTO data VALUES (2,1,6.5);
INSERT INTO data VALUES (2,2,7.5);
INSERT INTO data VALUES (2,2,8.5);
INSERT INTO keyset SELECT DISTINCT key, ref FROM data;
CREATE OR REPLACE VIEW drk_xml_view OF XMLType
with OBJECT ID
extract(object_value,'/ref').getnumberval()
AS
SELECT xmlElement(
"ref",
xmlElement("ref_id", refs.ref),
(SELECT xmlAgg(
xmlElement("key",
xmlElement("key_id",keyset.key),
xmlElement("values",
(SELECT xmlAgg(xmlElement("value",data.value))
FROM data
WHERE data.key=keyset.key AND data.ref=keyset.ref)
FROM keyset WHERE refs.ref = keyset.ref
) FROM refs
/When I do a query like:
SELECT xmlQuery('for $i in /ref return max($i/key/values/value)' passing object_value returning content) from drk_xml_view;the explain plan looks as expected:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 26 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 65 | | |
| 2 | NESTED LOOPS | | 1 | 65 | 6 (0)| 00:00:01 |
|* 3 | INDEX FAST FULL SCAN| KEYSET_KR | 1 | 26 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | DATA_KRV | 1 | 39 | 3 (0)| 00:00:01 |
| 5 | SORT AGGREGATE | | 1 | | | |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | TABLE ACCESS FULL | REFS | 2 | 26 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter("KEYSET"."REF"=:B1)
4 - access("DATA"."KEY"="KEYSET"."KEY" AND "DATA"."REF"=:B1)
filter("DATA"."REF"="KEYSET"."REF")
Note
- dynamic sampling used for this statementThis is very nicely optimized.
But now I do this one:
SELECT xmlQuery('for $i in /ref[./ref_id<2] return max($i/key/values/value)' passing object_value returning content) from drk_xml_view;(where I only added a constraint on the /ref/ref_id) the following occurs:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 26 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
| 2 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | |
| 3 | SORT AGGREGATE | | 1 | | | |
|* 4 | FILTER | | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | REFS | 2 | 26 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - filter(:B1<2)
Note
- dynamic sampling used for this statementSo, it doesn't use any index any more and creates a XMLSequenceFromXMLType instead. This one is then parsed which results in really bad performance.
I've tried to add extra indexes to the tables, but that didn't result in an optimilization. From a SQL point of view this seems quite easy, but using the view it gives me problems.
Is there someone who can explain me what is happening here? Or give me some pointers?
Please let me know if you need to know more, or if something is unclear.
Best regardsSQL> SELECT xmlQuery('for $i in /ref where $i/ref_id < 2 return max($i/key/values/value) ' passing object_value returning content)
2 from drk_xml_view
3 /
XMLQUERY('FOR$IIN/REFWHERE$I/REF_ID<2RETURNMAX($I/KEY/VALUES/VALUE)'PASSINGOBJECT_VALUERETURNINGCONTENT)
4.5
Execution Plan
Plan hash value: 2754328746
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 26 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 65 | | |
|* 2 | HASH JOIN | | 1 | 65 | 5 (20)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| KEYSET | 1 | 26 | 2 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL| DATA | 1 | 39 | 2 (0)| 00:00:01 |
| 5 | SORT AGGREGATE | | 1 | | | |
|* 6 | FILTER | | | | | |
| 7 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 8 | TABLE ACCESS FULL | REFS | 2 | 26 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("DATA"."KEY"="KEYSET"."KEY" AND
"DATA"."REF"="KEYSET"."REF")
3 - filter("KEYSET"."REF"=:B1)
4 - filter("DATA"."REF"=:B1)
6 - filter(:B1<2)
Note
- dynamic sampling used for this statement
SQL> -
XMLType column based on XML Schema: several questions
Hi,
I've a table on an oracle db version 10.1.0.4 where I stage the xml files containing orders created on a third party's system using BizTalk.
Although the storage I opted for is based on an XML Schema, defined by this third-party, I am facing big perfomance issues with files bigger than a few hundreds of kBs.
For instance, a 32Mb file takes more than 2 hours to be processed.
Now, after reading other threads in this forum and the documentation, my understanding of the problem is that the whole issue is with the correct indexing of the nested tables.
Here is my current XML Schema definition:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xdb:storeVarrayAsTable="true">
<xs:include schemaLocation="private/Types.xsd"/>
<xs:element name="PickData">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="ProdRun">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Nr" type="xs:int"/>
<xs:element name="Date" type="string8"/>
<xs:element name="Final" type="xs:int"/>
<xs:element name="PickWave" maxOccurs="unbounded">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Nr" type="string10"/>
<xs:element name="ProdLine" type="string2"/>
<xs:element name="TourSeq" type="xs:int"/>
<xs:element name="Tour" type="string20"/>
<xs:element name="Customer" maxOccurs="unbounded">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Seq" type="string20"/>
<xs:element name="Cust" type="string10"/>
<xs:element name="Mod" type="string30"/>
<xs:element name="Tod" type="string30"/>
<xs:element name="InvOrder" maxOccurs="unbounded">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Nr" type="string20"/>
<xs:element name="Item" type="string20"/>
<xs:element name="Qty" type="xs:int"/>
<xs:element name="Priority" type="xs:int"/>
<xs:element name="Reordering" type="xs:int"/>
<xs:element name="DelDate" type="string8"/>
<xs:element name="HlOrder" type="string20"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="InvOrderKey">
<xs:selector xpath="InvOrder"/>
<xs:field xpath="Nr"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="CustomerKey">
<xs:selector xpath="Customer"/>
<xs:field xpath="Seq"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="PickWaveKey">
<xs:selector xpath="PickWave"/>
<xs:field xpath="Nr"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="ProdRunKey">
<xs:selector xpath="ProdRun"/>
<xs:field xpath="Nr"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here is the included sub-schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="string2">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string5">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string6">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="6"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string8">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="8"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string10">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string15">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="15"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string20">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string30">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string40">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="40"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string50">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string250">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="250"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
The statement for creating my table is
CREATE TABLE "XML_ORDERS"
("ID" NUMBER(7,0) NOT NULL ENABLE,
"XMLFILE" "SYS"."XMLTYPE" ,
"INSERTED" DATE DEFAULT sysdate,
CONSTRAINT "XML_ORDERS_PK" PRIMARY KEY ("ID") USING INDEX ENABLE
) XMLTYPE COLUMN XMLFILE STORE AS OBJECT RELATIONAL
XMLSCHEMA "private/PickData.xsd" ELEMENT "PickData"
Here is a simple instance document:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PickData xsi:noNamespaceSchemaLocation="private/PickData.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ProdRun>
<Nr>5</Nr>
<Date>15112005</Date>
<Final>1</Final>
<PickWave>
<Nr>IPW0000017</Nr>
<ProdLine>01</ProdLine>
<TourSeq>1</TourSeq>
<Tour>00000043_078</Tour>
<Customer>
<Seq>5</Seq>
<Cust>100000006</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000457</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000742</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000459</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000742</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>6</Seq>
<Cust>100000013</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000461</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000743</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000463</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000743</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>2</Seq>
<Cust>100000114</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000465</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000744</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000467</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000744</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>3</Seq>
<Cust>100000140</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000469</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000745</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000471</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000745</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>7</Seq>
<Cust>100000143</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000473</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000746</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000475</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000746</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>8</Seq>
<Cust>100000145</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000477</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000747</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000479</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000747</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>9</Seq>
<Cust>100000146</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000481</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>0</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000748</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000483</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000748</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>4</Seq>
<Cust>100000147</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000485</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>0</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000750</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000487</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000750</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>10</Seq>
<Cust>100000148</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000489</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>0</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000751</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000491</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000751</HlOrder>
</InvOrder>
</Customer>
</PickWave>
</ProdRun>
</PickData>
When I registered the XMLSchema, the following types and tables were automatically created and you can see the hierarchy below:
(by the way, I could not find any xdb_utilities.printNestedTables mentioned elsewhere)
XML_ORDERS
|_PickData381_T
|___ProdRun382_T
|_____PickWave388_COLL
|_______PickWave383_T
|_________Customer387_COLL
|___________Customer384_T
|_____________InvOrder386_COLL
These objects are then used in the following nested tables:
TABLE_NAME TABLE_TYPE_NAME PARENT_TABLE_NAME PARENT_TABLE_COLUMN
SYS_NTaK/5zar5S0WitSsgu6OKPQ== PickWave388_COLL PickData389_TAB "XMLDATA"."ProdRun"."PickWave"
SYS_NTf6QvwVm8SFKz+K/YYWq+WQ== Item408_COLL ProdData409_TAB "XMLDATA"."Item"
SYS_NTtu05ilrRQqmuEN4k+07VDA== Customer402_COLL OutboundParty403_TAB "XMLDATA"."Customer"
SYS_NTK6fhWq5uTJ+vKcgBpNm1Fg== InvOrder386_COLL SYS_NTIIzv7bkXQSSS43igtfi5eg== InvOrder
SYS_NTIIzv7bkXQSSS43igtfi5eg== Customer387_COLL SYS_NTaK/5zar5S0WitSsgu6OKPQ== Customer
I enabled sql tracing and I got the following TKPROF output
INSERT INTO IMP_ORDERS (PICK_INVORDERNR, PICK_ITEM, PICK_QTY, PICK_PRIORITY,
PICK_REORDERING, PICK_HLORDER, PICK_DELDATE, PICK_CUST, PICK_MOD, PICK_TOD,
PICK_SEQ, PICK_PICKWAVENR, PICK_PICKWAVEPRODLINE, PICK_PICKWAVETOUR,
PICK_PICKWAVETOURSEQ, PICK_ORDKEY, PICK_RUNKEY) SELECT INVORDERNR, ITEM,
QTY, PRIORITY, REORDERING, HLORDER, DELDATE, CUST, MOD, TOD, SEQ,
PICKWAVENR, PICKWAVEPRODLINE, PICKWAVETOUR, PICKWAVETOURSEQ, ROWNUM AS
PICK_ORDKEY, PRODRUNID FROM (SELECT /*+ cardinality(g 15)*/
EXTRACTVALUE(VALUE(G), '/InvOrder/Nr') AS INVORDERNR, EXTRACTVALUE(VALUE(G),
'/InvOrder/Item') AS ITEM, EXTRACTVALUE(VALUE(G), '/InvOrder/Qty') AS QTY,
EXTRACTVALUE(VALUE(G), '/InvOrder/Priority') AS PRIORITY,
EXTRACTVALUE(VALUE(G), '/InvOrder/Reordering') AS REORDERING,
EXTRACTVALUE(VALUE(G), '/InvOrder/HlOrder') AS HLORDER,
TO_DATE(EXTRACTVALUE(VALUE(G), '/InvOrder/DelDate'),'DDMMYYYY') AS DELDATE,
F.CUST, F.MOD, F.TOD, F.SEQ, F.PICKWAVENR, F.PICKWAVEPRODLINE,
F.PICKWAVETOUR, F.PICKWAVETOURSEQ, F.PRODRUNNR, F.PRODRUNDATE,
F.PRODRUNFINAL, F.PRODRUNID FROM (SELECT /*+ cardinality(e 60)*/VALUE(E) AS
CUSTOMERNODE, EXTRACTVALUE(VALUE(E), '/Customer/Cust') AS CUST,
EXTRACTVALUE(VALUE(E), '/Customer/Mod') AS MOD, EXTRACTVALUE(VALUE(E),
'/Customer/Tod') AS TOD, TO_NUMBER(EXTRACTVALUE(VALUE(E), '/Customer/Seq'))
AS SEQ, D.PICKWAVENR, D.PICKWAVEPRODLINE, D.PICKWAVETOUR, D.PICKWAVETOURSEQ,
D.PRODRUNNR, D.PRODRUNDATE, D.PRODRUNFINAL, D.PRODRUNID FROM (SELECT /*+
cardinality(c 100)*/VALUE(C) AS PICKWAVENODE, EXTRACTVALUE(VALUE(C),
'/PickWave/Nr') AS PICKWAVENR, TO_NUMBER(EXTRACTVALUE(VALUE(C),
'/PickWave/ProdLine')) AS PICKWAVEPRODLINE, EXTRACTVALUE(VALUE(C),
'/PickWave/Tour') AS PICKWAVETOUR, TO_NUMBER(EXTRACTVALUE(VALUE(C),
'/PickWave/TourSeq')) AS PICKWAVETOURSEQ, A.PRODRUNNR, A.PRODRUNDATE,
A.PRODRUNFINAL, A.PRODRUNID FROM (SELECT /*+ cardinality(b 1)*/VALUE(B) AS
PRODRUNNODE, EXTRACTVALUE(VALUE(B), '/ProdRun/Nr') AS PRODRUNNR,
TO_DATE(EXTRACTVALUE(VALUE(B), '/ProdRun/Date'),'DDMMYYYY') AS PRODRUNDATE,
EXTRACTVALUE(VALUE(B), '/ProdRun/Final') AS PRODRUNFINAL, X.ID PRODRUNID
FROM XML_ORDERS X, TABLE(XMLSEQUENCE(EXTRACT(X.XMLFILE,'/PickData/ProdRun'))
) B WHERE X.ID = :B1 ) A, TABLE(XMLSEQUENCE(EXTRACT(A.PRODRUNNODE,
'/ProdRun/PickWave'))) C ) D, TABLE(XMLSEQUENCE(EXTRACT(D.PICKWAVENODE,
'/PickWave/Customer'))) E ) F, TABLE(XMLSEQUENCE(EXTRACT(F.CUSTOMERNODE,
'/Customer/InvOrder'))) G ORDER BY PICKWAVEPRODLINE, PICKWAVETOURSEQ,
PICKWAVENR, SEQ )
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 4324.09 9994.65 0 57193 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 4324.09 9994.65 0 57193 0 0
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 68 (recursive depth: 1)
Rows Row Source Operation
0 COUNT (cr=0 pr=0 pw=0 time=180 us)
0 VIEW (cr=0 pr=0 pw=0 time=166 us)
0 SORT ORDER BY (cr=0 pr=0 pw=0 time=152 us)
40866 NESTED LOOPS (cr=54973 pr=0 pw=0 time=31065606 us)
1363 NESTED LOOPS (cr=54937 pr=0 pw=0 time=11037183 us)
1 NESTED LOOPS (cr=54889 pr=0 pw=0 time=10145883 us)
1 NESTED LOOPS (cr=54841 pr=0 pw=0 time=9799012 us)
1 TABLE ACCESS BY INDEX ROWID XML_ORDERS (cr=2 pr=0 pw=0 time=222 us)
1 INDEX UNIQUE SCAN XML_ORDERS_PK (cr=1 pr=0 pw=0 time=126 us)(object id 58551)
1 COLLECTION ITERATOR PICKLER FETCH (cr=54839 pr=0 pw=0 time=9798748 us)
1 COLLECTION ITERATOR PICKLER FETCH (cr=48 pr=0 pw=0 time=346818 us)
1363 COLLECTION ITERATOR PICKLER FETCH (cr=48 pr=0 pw=0 time=870830 us)
40866 COLLECTION ITERATOR PICKLER FETCH (cr=36 pr=0 pw=0 time=18739302 us)
Note that I cancelled this operation before it was over so I imagine that these figures refer to the statistics as of the time when the operation was interrupted.
So, here are finally my questions.
In order to create the constraints on the nested tables as shown in other threads, do I need to drop the existing xml_orders table and ancillary object types and recreate them or is there a way to add such constraints using the existing system generated object names?
Secondly, the xml_orders table may contain severale documents, not just one and his current primary key is the column ID. So, in order to uniquely identify the deepest element in the xml document, I need first to select the relevant document by means of the id column.
Would it be better to create the indexes containing this id column together with the nested_table_id and array_index?
Thanks for you help.
Flavio
PS: I wrote a 10 lines xsl transformation that I passed on to Saxon together with the 32Mb file. It took less than 1 minute to produce a flat file that was loaded almost instantly by SQL*Loader. So, what I am looking for is a procedure loading this stuff in less than 2 minutes or possibly less.Does the following help
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:53 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool registerSchema_&4..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> declare
2 result boolean;
3 begin
4 result := dbms_xdb.createResource('/home/&1/xsd/&4',
5 bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
6 end;
7 /
old 4: result := dbms_xdb.createResource('/home/&1/xsd/&4',
new 4: result := dbms_xdb.createResource('/home/OTNTEST/xsd/GetaxTypes.xsd',
old 5: bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
new 5: bfilename(USER,'GetaxTypes.xsd'),nls_charset_id('AL32UTF8'));
PL/SQL procedure successfully completed.
SQL> commit
2 /
Commit complete.
SQL> alter session set events='31098 trace name context forever'
2 /
Session altered.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 schemaURL => '&3',
5 schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
6 local => TRUE,
7 genTypes => TRUE,
8 genBean => FALSE,
9 genTables => &5
10 );
11 end;
12 /
old 4: schemaURL => '&3',
new 4: schemaURL => 'private/GetaxTypes.xsd',
old 5: schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
new 5: schemaDoc => xdbURIType('/home/OTNTEST/xsd/GetaxTypes.xsd').getClob(),
old 9: genTables => &5
new 9: genTables => TRUE
PL/SQL procedure successfully completed.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:55 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool registerSchema_&4..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> declare
2 result boolean;
3 begin
4 result := dbms_xdb.createResource('/home/&1/xsd/&4',
5 bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
6 end;
7 /
old 4: result := dbms_xdb.createResource('/home/&1/xsd/&4',
new 4: result := dbms_xdb.createResource('/home/OTNTEST/xsd/PickData.xsd',
old 5: bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
new 5: bfilename(USER,'PickData.xsd'),nls_charset_id('AL32UTF8'));
PL/SQL procedure successfully completed.
SQL> commit
2 /
Commit complete.
SQL> alter session set events='31098 trace name context forever'
2 /
Session altered.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 schemaURL => '&3',
5 schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
6 local => TRUE,
7 genTypes => TRUE,
8 genBean => FALSE,
9 genTables => &5
10 );
11 end;
12 /
old 4: schemaURL => '&3',
new 4: schemaURL => 'private/PickData.xsd',
old 5: schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
new 5: schemaDoc => xdbURIType('/home/OTNTEST/xsd/PickData.xsd').getClob(),
old 9: genTables => &5
new 9: genTables => TRUE
PL/SQL procedure successfully completed.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:58 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool createTable.log
SQL> --
SQL> connect &1/&2
Connected.
SQL> --
SQL> CREATE TABLE "XML_ORDERS"
2 ("ID" NUMBER(7,0) NOT NULL ENABLE,
3 "XMLFILE" "SYS"."XMLTYPE" ,
4 "INSERTED" DATE DEFAULT sysdate,
5 CONSTRAINT "XML_ORDERS_PK" PRIMARY KEY ("ID") USING INDEX ENABLE
6 ) XMLTYPE COLUMN XMLFILE STORE AS OBJECT RELATIONAL
7 XMLSCHEMA "private/PickData.xsd"
8 ELEMENT "PickData"
9 VARRAY XMLFILE."XMLDATA"."ProdRun"."PickWave" STORE AS TABLE PickWave_TAB
10 (
11 ( primary key (nested_table_id, array_index)
12 ) organization index overflow
13 VARRAY "Customer" STORE AS TABLE Customer_TAB
14 (
15 (primary key (nested_table_id, array_index)
16 ) organization index overflow
17 VARRAY "InvOrder" STORE AS TABLE InvOrder_TAB
18 (
19 (primary key (nested_table_id, array_index)
20 ) organization index overflow
21 )
22 )
23 )
24 /
Table created.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:59 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool insertFile_&3..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> set timing on
SQL> set long 10000
SQL> --
SQL> insert into XML_ORDERS (ID, XMLFILE) values (&4, xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
2 /
old 1: insert into XML_ORDERS (ID, XMLFILE) values (&4, xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
new 1: insert into XML_ORDERS (ID, XMLFILE) values (10, xmltype(bfilename(USER,'testcase.xml'),nls_charset_id('AL32UT
8')))
1 row created.
Elapsed: 00:00:00.11
SQL> commit
2 /
Commit complete.
Elapsed: 00:00:00.01
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:59 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool testcase.log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> set timing on
SQL> set long 10000
SQL> set pages 0 lines 140
SQL> --
SQL> -- Testcase code here
SQL> --
SQL> set autotrace on explain
SQL> --
SQL> create or replace view PROD_RUN_VIEW
2 (
3 PRODRUNNODE,
4 PRODRUNNR,
5 PRODRUNDATE,
6 PRODRUNID,
7 PRODRUNFINAL
8 )
9 as
10 select EXTRACT(XMLFILE,'/PickData/ProdRun'),
11 EXTRACTVALUE(XMLFILE , '/PickData/ProdRun/Nr'),
12 TO_DATE(EXTRACTVALUE(XMLFILE, '/PickData/ProdRun/Date'),'DDMMYYYY'),
13 ID,
14 EXTRACTVALUE(XMLFILE,'/PickData/ProdRun/Final')
15 from XML_ORDERS
16 /
View created.
Elapsed: 00:00:00.09
SQL> create or replace view PICK_WAVE_VIEW
2 (
3 PICKWAVENODE,
4 PICKWAVENR,
5 PICKWAVEPRODLINE,
6 PICKWAVETOUR,
7 PICKWAVETOURSEQ,
8 PRODRUNNR,
9 PRODRUNDATE,
10 PRODRUNID,
11 PRODRUNFINAL
12 )
13 as
14 select value(PW),
15 extractValue(value(PW),'/PickWave/Nr'),
16 TO_NUMBER(EXTRACTVALUE(value(PW),'/PickWave/ProdLine')),
17 extractValue(value(PW),'/PickWave/Tour'),
18 TO_NUMBER(extractValue(value(PW),'/PickWave/TourSeq')),
19 PRODRUNNR,
20 PRODRUNDATE,
21 PRODRUNID,
22 PRODRUNFINAL
23 FROM PROD_RUN_VIEW, table(xmlsequence(extract(PRODRUNNODE,'/ProdRun/PickWave'))) PW
24 /
View created.
Elapsed: 00:00:00.09
SQL> create or replace view CUSTOMER_VIEW
2 (
3 CUSTOMERNODE,
4 CUST,
5 MOD,
6 TOD,
7 SEQ,
8 PICKWAVENR,
9 PICKWAVEPRODLINE,
10 PICKWAVETOUR,
11 PICKWAVETOURSEQ,
12 PRODRUNNR,
13 PRODRUNDATE,
14 PRODRUNFINAL,
15 PRODRUNID
16 )
17 as
18 select value(CUST),
19 EXTRACTVALUE(VALUE(CUST), '/Customer/Cust'),
20 EXTRACTVALUE(VALUE(CUST), '/Customer/Mod'),
21 EXTRACTVALUE(VALUE(CUST), '/Customer/Tod'),
22 TO_NUMBER(EXTRACTVALUE(VALUE(CUST), '/Customer/Seq')),
23 PICKWAVENR,
24 PICKWAVEPRODLINE,
25 PICKWAVETOUR,
26 PICKWAVETOURSEQ,
27 PRODRUNNR,
28 PRODRUNDATE,
29 PRODRUNFINAL,
30 PRODRUNID
31 from PICK_WAVE_VIEW, table(xmlsequence(extract(PICKWAVENODE,'/PickWave/Customer'))) CUST
32 /
View created.
Elapsed: 00:00:00.10
SQL>
SQL> create or replace view INVOICE_ORDER_VIEW
2 (
3 INVORDERNR,
4 ITEM,
5 QTY,
6 PRIORITY,
7 REORDERING,
8 HLORDER,
9 DELDATE,
10 CUST,
11 MOD,
12 TOD,
13 SEQ,
14 PICKWAVENR,
15 PICKWAVEPRODLINE,
16 PICKWAVETOUR,
17 PICKWAVETOURSEQ,
18 PRODRUNNR,
19 PRODRUNDATE,
20 PRODRUNFINAL,
21 PRODRUNID
22 )
23 as
24 SELECT EXTRACTVALUE(VALUE(INV), '/InvOrder/Nr'),
25 EXTRACTVALUE(VALUE(INV), '/InvOrder/Item'),
26 EXTRACTVALUE(VALUE(INV), '/InvOrder/Qty'),
27 EXTRACTVALUE(VALUE(INV), '/InvOrder/Priority'),
28 EXTRACTVALUE(VALUE(INV), '/InvOrder/Reordering'),
29 EXTRACTVALUE(VALUE(INV), '/InvOrder/HlOrder'),
30 TO_DATE(EXTRACTVALUE(VALUE(INV), '/InvOrder/DelDate'),'DDMMYYYY'),
31 CUST,
32 MOD,
33 TOD,
34 SEQ,
35 PICKWAVENR,
36 PICKWAVEPRODLINE,
37 PICKWAVETOUR,
38 PICKWAVETOURSEQ,
39 PRODRUNNR,
40 PRODRUNDATE,
41 PRODRUNFINAL,
42 PRODRUNID
43 FROM CUSTOMER_VIEW, table(xmlsequence(extract(CUSTOMERNODE,'Customer/InvOrder'))) INV
44 /
View created.
Elapsed: 00:00:00.13
SQL> select * from INVOICE_ORDER_VIEW
2 /
IIO0000461 100000036 20 1 0 CSO000743 15-NOV-05 100000013
FO DDU 6 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000463 100000045 20 1 0 CSO000743 15-NOV-05 100000013
FO DDU 6 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000473 100000036 20 1 0 CSO000746 15-NOV-05 100000143
FO DDU 7 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000475 100000045 20 1 0 CSO000746 15-NOV-05 100000143
FO DDU 7 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000469 100000036 20 1 0 CSO000745 15-NOV-05 100000140
FO DDU 3 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000471 100000045 20 1 0 CSO000745 15-NOV-05 100000140
FO DDU 3 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000489 100000036 20 0 0 CSO000751 15-NOV-05 100000148
FO DDU 10 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000491 100000045 20 1 0 CSO000751 15-NOV-05 100000148
FO DDU 10 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000481 100000036 20 0 0 CSO000748 15-NOV-05 100000146
FO DDU 9 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000483 100000045 20 1 0 CSO000748 15-NOV-05 100000146
FO DDU 9 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000485 100000036 20 0 0 CSO000750 15-NOV-05 100000147
FO DDU 4 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000487 100000045 20 1 0 CSO000750 15-NOV-05 100000147
FO DDU 4 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000457 100000036 20 1 0 CSO000742 15-NOV-05 100000006
FO DDU 5 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000459 100000045 20 1 0 CSO000742 15-NOV-05 100000006
FO DDU 5 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000477 100000036 20 1 0 CSO000747 15-NOV-05 100000145
FO DDU 8 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000479 100000045 20 1 0 CSO000747 15-NOV-05 100000145
FO DDU 8 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000465 100000036 20 1 0 CSO000744 15-NOV-05 100000114
FO DDU 2 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000467 100000045 20 1 0 CSO000744 15-NOV-05 100000114
FO DDU 2 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
18 rows selected.
Elapsed: 00:00:00.22
Execution Plan
Plan hash value: 1730223965
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 18 | 10278 | 877 (0)| 00:00:11 |
| 1 | NESTED LOOPS | | 18 | 10278 | 877 (0)| 00:00:11 |
| 2 | NESTED LOOPS | | 18 | 8424 | 841 (0)| 00:00:11 |
| 3 | MERGE JOIN CARTESIAN | | 18 | 4680 | 805 (0)| 00:00:10 |
| 4 | TABLE ACCESS FULL | XML_ORDERS | 1 | 67 | 3 (0)| 00:00:01 |
| 5 | BUFFER SORT | | 18 | 3474 | 802 (0)| 00:00:10 |
| 6 | INDEX FAST FULL SCAN| SYS_IOT_TOP_64187 | 18 | 3474 | 802 (0)| 00:00:10 |
|* 7 | INDEX UNIQUE SCAN | SYS_IOT_TOP_64185 | 1 | 208 | 2 (0)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | SYS_C008783 | 1 | | 0 (0)| 00:00:01 |
|* 9 | INDEX UNIQUE SCAN | SYS_IOT_TOP_64183 | 1 | 103 | 2 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | SYS_C008785 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
7 - access("NESTED_TABLE_ID"="CUSTOMER_TAB"."SYS_NC0000800009$")
8 - access("NESTED_TABLE_ID"="CUSTOMER_TAB"."SYS_NC0000800009$")
9 - access("NESTED_TABLE_ID"="PICKWAVE_TAB"."SYS_NC0000800009$")
filter("NESTED_TABLE_ID"="XML_ORDERS"."SYS_NC0001000011$")
10 - access("NESTED_TABLE_ID"="PICKWAVE_TAB"."SYS_NC0000800009$")
Note
- dynamic sampling used for this statement
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
C:\oracle\xdb\otn\347125>You were sequencing the ProdRun node, which is a mistake. Only nodes which occur multiple times should be sequenced... -
Table in Schema1 using XMLIndexes But not in View- Schema2
Hi,
We are using :
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit
I have a view with following query:
CREATE OR REPLACE FORCE VIEW VIEW_TNAME
XML
AS
SELECT Column_Name
FROM TNAME
WHERE XMLEXISTS (
'declare namespace Namesp1 ="Abc:Set"; declare Namespace Namesp2 ="XYZ:Set"; declare namespace Namesp3 ="DEF:Set"; /Namesp1:Tag1/Namesp2:Tag2/Namesp3:Tag3[@id="ID"][Namesp2:Tag5[@Scope="SCOPE"] = ("1000", "2000") ]'
PASSING Column_Name);
Table TNAME is in Schema1.
View VIEW_TNAME is in Schema2.
When I execute the query in Schema1(without the view. i.e. Just execute underlying query).
Plan is like:
Plan
SELECT STATEMENT ALL_ROWSCost: 86 Bytes: 124 Cardinality: 1
20 NESTED LOOPS Cost: 86 Bytes: 124 Cardinality: 1
18 VIEW VIEW SYS.VW_SQ_1 Cost: 84 Bytes: 25 Cardinality: 1
17 HASH UNIQUE Bytes: 190 Cardinality: 1
16 NESTED LOOPS Cost: 84 Bytes: 190 Cardinality: 1
13 NESTED LOOPS Cost: 84 Bytes: 143 Cardinality: 1
9 NESTED LOOPS Cost: 65 Bytes: 96 Cardinality: 1
6 HASH JOIN RIGHT SEMI Cost: 64 Bytes: 490 Cardinality: 10
1 COLLECTION ITERATOR PICKLER FETCH PROCEDURE SYS.XQSEQUENCEFROMXMLTYPE Cost: 35 Bytes: 32,720 Cardinality: 16,360
5 PX COORDINATOR
4 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10000 :Q1000Cost: 28 Bytes: 442,599 Cardinality: 9,417
3 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1000Cost: 28 Bytes: 442,599 Cardinality: 9,417 Partition #: 11 Partitions accessed #1 - #282
2 TABLE ACCESS FULL TABLE PARALLEL_COMBINED_WITH_PARENT Schema_Name.TNAME_RANGE_PT :Q1000Cost: 28 Bytes: 442,599 Cardinality: 9,417 Partition #: 11 Partitions accessed #1 - #282
8 PARTITION SYSTEM ITERATOR Cost: 1 Bytes: 47 Cardinality: 1 Partition #: 13 Partitions determined by Key Values
7 TABLE ACCESS FULL TABLE Schema_Name.TNAME_RANGE_PT Cost: 1 Bytes: 47 Cardinality: 1 Partition #: 13 Partitions determined by Key Values
12 PARTITION SYSTEM ALL Cost: 20 Bytes: 47 Cardinality: 1 Partition #: 15 Partitions accessed #1 - #282
11 TABLE ACCESS BY LOCAL INDEX ROWID TABLE Schema_Name.TNAME_RANGE_PT Cost: 20 Bytes: 47 Cardinality: 1 Partition #: 15 Partitions accessed #1 - #282
10 INDEX RANGE SCAN INDEX Schema_Name.SYS803074_I_XPATH_T_PIKEY_IX Cost: 20 Cardinality: 1 Partition #: 15 Partitions accessed #1 - #282
15 PARTITION SYSTEM ITERATOR Cost: 1 Bytes: 47 Cardinality: 1 Partition #: 18 Partitions determined by Key Values
14 TABLE ACCESS FULL TABLE Schema_Name.TNAME_RANGE_PT Cost: 1 Bytes: 47 Cardinality: 1 Partition #: 18 Partitions determined by Key Values
19 TABLE ACCESS BY USER ROWID TABLE Schema_Name.TNAME Cost: 1 Bytes: 99 Cardinality: 1 Partition #: 20 Partition access computed by row location
Query uses the XMLIndexes and gets executed in ~20 seconds.
BUT
When I execute the same query in Schema2 or query the view which is built in Schema2. Explain Plan is like:
<ExplainPlan>
- <PlanElement id="0" operation="SELECT STATEMENT" optimizer="ALL_ROWS" search_columns="0" cost="48,865">
- <PlanElements>
- <PlanElement id="1" operation="FILTER" search_columns="0" filter_predicates="IS NOT NULL">
- <PlanElements>
- <PlanElement id="2" operation="PARTITION RANGE" option="ALL" search_columns="0" cost="48,805" cardinality="1,269,600" bytes="1,274,678,400" partition_id="2" partition_start="1" partition_stop="282" cpu_cost="1,932,647,487" io_cost="48,744" time="684">
- <PlanElements>
<PlanElement object_ID="0" id="3" operation="TABLE ACCESS" option="FULL" object_owner="Schema_Name" object_name="TNAME" object_type="TABLE" search_columns="0" cost="48,805" cardinality="1,269,600" bytes="1,274,678,400" partition_id="2" partition_start="1" partition_stop="282" cpu_cost="1,932,647,487" io_cost="48,744" time="684" />
</PlanElements>
</PlanElement>
- <PlanElement id="4" operation="HASH JOIN" option="RIGHT SEMI" search_columns="0" cost="60" cardinality="1" bytes="18" cpu_cost="27,206,479" io_cost="59" access_predicates="<not feasible>" time="1">
- <PlanElements>
<PlanElement object_ID="1" id="5" operation="COLLECTION ITERATOR" option="PICKLER FETCH" object_owner="SYS" object_name="XQSEQUENCEFROMXMLTYPE" object_type="PROCEDURE" search_columns="0" cost="35" cardinality="16,360" bytes="32,720" cpu_cost="3,428,288" io_cost="35" time="1" />
- <PlanElement id="6" operation="NESTED LOOPS" search_columns="0" cost="24" cardinality="100" bytes="800" cpu_cost="5,560,801" io_cost="24" time="1">
- <PlanElements>
<PlanElement id="7" operation="XPATH EVALUATION" search_columns="0" />
<PlanElement id="8" operation="XPATH EVALUATION" search_columns="0" />
(Sorry about the tags in the Plan).
As shown in the plan, XMLIndexes are not used and query goes into forever execution as there are millions of rows in table TNAME.
- Why this difference of behaviour in two schemas. It happens on some views like this one and not on others.
- How can I correct this. ( I changed parameter OPTIMIZER_SECURE_VIEW_MERGING to FALSE. It looks like that solved the problem in our environment. But getting it done in PRODUCTION looks like Very Difficult and Process Oriented unless there is no other way).
Kindly suggest. Thanks.Hi,
Table Structure is as follows:
CREATE TABLE TNAME
DB_ID VARCHAR2(10 BYTE),
DATA_ID VARCHAR2(10 BYTE),
DATA_ID2 VARCHAR2(10 BYTE),
IDENTIFIER1 NUMBER(19) NOT NULL,
ID1 NUMBER(10) NOT NULL,
STATUS1 NUMBER(10) NOT NULL,
TIME_STAMP NUMBER(19) NOT NULL,
OBJECT_ID VARCHAR2(40 BYTE) NOT NULL,
OBJECT_NAME VARCHAR2(80 BYTE) NOT NULL,
UNIQUE_ID VARCHAR2(255 BYTE),
DATA_LIVE CHAR(1 BYTE) NOT NULL,
XML_MESSAGE SYS.XMLTYPE,
ID2 VARCHAR2(255 BYTE) NOT NULL,
FLAG1 CHAR(1 BYTE) NOT NULL,
KEY1 VARCHAR2(255 BYTE),
HEADER1 VARCHAR2(2000 BYTE) NOT NULL,
VERSION2 VARCHAR2(255 BYTE) NOT NULL,
TYPE1 VARCHAR2(15 BYTE),
LOAD_TIMESTAMP TIMESTAMP(6),
SOURCE_NUMBER NUMBER
XMLTYPE XML_MESSAGE STORE AS BINARY XML (
TABLESPACE TSNAME)
TABLESPACE TSNAME
PARTITION BY RANGE (LOAD_TIMESTAMP)
PARTITION MAX VALUES LESS THAN (MAXVALUE)
TABLESPACE TSNAME
NOCOMPRESS
NOCACHE
ENABLE ROW MOVEMENT
Indexes are:
CREATE UNIQUE INDEX "TNAME_UQI"
ON "TNAME" (" DATA_ID", "IDENTIFIER1", "ID1")
PCTFREE 10
INITRANS 2
MAXTRANS 255
COMPUTE STATISTICS
TABLESPACE "TSNAME"
CREATE INDEX "TNAME_I"
ON "TNAME" ("SOURCE_NUMBER")
PCTFREE 10
INITRANS 2
MAXTRANS 255
COMPUTE STATISTICS
TABLESPACE "TSNAME"
-- XMLType Index is created as Register Parameter and then....
BEGIN
DBMS_XMLINDEX.REGISTERPARAMETER(
'TNAME_PAR',
'PATH TABLE TNAME_PT
PATHS (INCLUDE ( /abc:Msg/xyz:product/def:productType/def:SubProductType
/abc:Msg/xyz:Products/xyz:Owner
NAMESPACE MAPPING ( xmlns:abc="Abc:Set";
xmlns:xyz ="XYZ:Set"
xmlns:def="DEF:Set"
END;
CREATE INDEX I_XPATH_TNAME
ON "TNAME" (XML_MESSAGE)
INDEXTYPE IS XDB.XMLINDEX PARAMETERS ( 'PARAM TNAME_PAR',)
local
Now the view is like:
CREATE OR REPLACE FORCE VIEW VIEW_TNAME
XML
AS
SELECT XML_MESSAGE
FROM TNAME
WHERE XMLEXISTS (
'declare namespace abc ="Abc:Set"; declare Namespace xyz ="XYZ:Set"; declare namespace def ="DEF:Set"; /abc:Tag1/xyz:Tag2/def:Tag3[@id="ID"][EntityID:Tag5[@Scope="SCOPE"] = ("1000", "2000") ]'
PASSING XML_Message);
THROUGH this view we are filtering only the EntityID in 1000 or 2000 which is unique in the XML Message, based on certain crietrias as mentioned in the Path Expression.
Due to confidentiality I can't share the data here. :-(
But it's like..(XML File size is around 250 rows in every XML_Message) and around .2 million rows in the table in environment where I am testing.
But it will grow upto some millions later.
NOW I have table in SCHEMA1.
There if I execute this underlying query to view, plan is like:
| Id | Operation | Name | E-Rows | OMem | 1Mem | Used-Mem |
| 0 | SELECT STATEMENT | | | | | |
| 1 | NESTED LOOPS | | 1 | | | |
| 2 | VIEW | VW_SQ_1 | 1 | | | |
| 3 | HASH UNIQUE | | 1 | 926K| 926K| 1263K (0)|
| 4 | NESTED LOOPS | | 1 | | | |
| 5 | NESTED LOOPS | | 1 | | | |
| 6 | NESTED LOOPS | | 1 | | | |
|* 7 | HASH JOIN RIGHT SEMI | | 52 | 733K| 733K| 497K (0)|
| 8 | COLLECTION ITERATOR PICKLER FETCH| XQSEQUENCEFROMXMLTYPE | 16360 | | | |
| 9 | PX COORDINATOR | | | | | |
| 10 | PX SEND QC (RANDOM) | :TQ10000 | 59638 | | | |
| 11 | PX BLOCK ITERATOR | | 59638 | | | |
|* 12 | TABLE ACCESS FULL | TNAME_PT | 59638 | | | |
| 13 | PARTITION SYSTEM ITERATOR | | 1 | | | |
|* 14 | TABLE ACCESS FULL | TNAME_PT | 1 | | | |
| 15 | PARTITION SYSTEM ALL | | 1 | | | |
|* 16 | TABLE ACCESS BY LOCAL INDEX ROWID | TNAME_PT | 1 | | | |
|* 17 | INDEX RANGE SCAN | SYS803074_I_XPATH_T_PIKEY_IX | 1 | | | |
| 18 | PARTITION SYSTEM ITERATOR | | 1 | | | |
|* 19 | TABLE ACCESS FULL | TNAME_PT | 1 | | | |
|* 20 | TABLE ACCESS BY USER ROWID | TNAME | 1 | | | |
---------------------------------------------------------------------------------------------------------------------So I can see PATH Tables being used on which Index is registered and Execution is very fast.
Other PLAN when I execute the query from SCHEMA2, is going for FTS on table TNAME as:
Plan
SELECT STATEMENT ALL_ROWSCost: 39,887
8 FILTER
2 PARTITION RANGE ALL Cost: 39,827 Bytes: 447,179,616 Cardinality: 193,752 Partition #: 2 Partitions accessed #1 - #282
1 TABLE ACCESS FULL TABLE TNAME Cost: 39,827 Bytes: 447,179,616 Cardinality: 193,752 Partition #: 2 Partitions accessed #1 - #282
7 HASH JOIN RIGHT SEMI Cost: 60 Bytes: 18 Cardinality: 1
3 COLLECTION ITERATOR PICKLER FETCH PROCEDURE SYS.XQSEQUENCEFROMXMLTYPE Cost: 35 Bytes: 32,720 Cardinality: 16,360
6 NESTED LOOPS Cost: 24 Bytes: 800 Cardinality: 100
4 XPATH EVALUATION
5 XPATH EVALUATION fIRST THINGS FIRST- So is there any way I can make this view always use this index. ?
I have tried several ways including hints for Indexes but they simply don't seem to help.
Same query takes 15 secs in one schema and 2 hours in another.
Is there any way we can make the query through view always use these XMLType Indexes and not Inconsistently. It's a lot faster when XMLType Indexes are used. In fact it does not work in Production if XMLIndex is not used.
Kindly suggest..
Edited by: user8941550 on Jan 3, 2013 8:20 PM -
Slow SQL output when table alias is NOT used in order by clause
Hi guys,
My query is based on Oracle 9208
I have a table TAB1 with 68000 records with transaction_id as the primary key in this table (unique index).
I have another TAB2 with the same number of records again with transaction_id in this table (foreign key to above).
I have the below query that gets executed via an application:-
SELECT TO_CHAR(V1.TRANSACTION_ID), V1.POLICY_ID, V1.REQUEST_TYPE
FROM <VIEW> V1 WHERE V1.CERT_SERIAL_NUM=56192 AND
(V1.AUTH_GROUP_ID=0 OR V1.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
BY TRANSACTION_ID ASC
The above view V1 is created as below:-
CREATE OR REPLACE FORCE VIEW "V1"
("TRANSACTION_ID",
"PARENT_TRANSACTION_ID",
"CA_DN_ID",
"AUTH_GROUP_ID",
"POLICY_ID",
"REQUEST_TYPE",
"REQUEST_STATUS",
"EE_DN_HASH",
"EE_DN",
"EE_EMAIL_HASH",
"EE_EMAIL",
"KEY_USAGE",
"SMART_CARD_SERIAL",
"CERT_TYPE",
"CERT_SERIAL_NUM",
"CERT_INDEX",
"RENEWAL_FLAG",
"ARCHIVE_FLAG",
"TIME_RECEIVED",
"DOWNLOADED",
"REQUEST_DATA",
"ACTION",
"STEP_NUM")
AS
SELECT
T1.transaction_id,
T1.parent_transaction_id,
T1.ca_dn_id,
V2.auth_group_id,
V2.policy_id,
T1.request_type,
T1.request_status,
T2.ee_dn_hash,
T2.ee_dn,
T2.ee_email_hash,
T2.ee_email,
T2.key_usage,
T2.smart_card_serial,
T2.cert_type,
T2.cert_serial_num,
T2.cert_index,
T2.renewal_flag,
T2.archive_flag,
T1.time_received,
T1.downloaded,
T1.request_data,
V2.action,
V2.step_num
FROM TAB1
<ANOTHER VIEW> V2,
TAB2 T1,
TAB2 T2
WHERE
T1.transaction_id = T2.transaction_id
AND
V2.policy_id = T1.policy_id
order by transaction_id;
The query at the top runs within milliseconds if the VIEW is created as :-
order by t2.transaction_id
But without the alias "t2" in the order by, the query takes about 1 1/2 minutes
Can you tell me why? I thought if you ordering by primary key (lesser number of values compared to foreign key values), the query should be faster..no?
Thanks in advanceThanks for keeping up with this issue Hemant.
Here are the plans for each case.
I would be very interested in how you'd recognize which plan is the best and what are the derivatives.
I don't much (or rather anything!) what is 'card' values, 'cost' values etc which I believe are used to decide the best plan of the lot.
Thanks again
Note TAB1 and TAB2 are from view definition posted initially
1) Execution Plan for VIEW1 <<-- With ORDER BY" clause but no table ailas (order by transaction_id)
SQL> EXPLAIN PLAN FOR SELECT TO_CHAR(QT.TRANSACTION_ID), QT.POLICY_ID, QT.REQUEST_TYPE
2 FROM <VIEW1> QT WHERE QT.CERT_SERIAL_NUM=24293 AND
3 (QT.AUTH_GROUP_ID=0 OR QT.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
4 BY TRANSACTION_ID ASC
5 /
Explained.
Elapsed: 00:00:01.00
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 3 | 195 | 17 |
|* 1 | COUNT STOPKEY | | | | |
| 2 | VIEW | VIEW1 | 17 | 1105 | 17 |
|* 3 | SORT ORDER BY STOPKEY | | 17 | 38573 | 17 |
| 4 | NESTED LOOPS | | 17 | 38573 | 10 |
| 5 | MERGE JOIN CARTESIAN | | 1 | 167 | 9 |
| 6 | VIEW | VIEW2 | 1 | 52 | 8 |
| 7 | SORT UNIQUE | | 1 | 156 | 8 |
| 8 | NESTED LOOPS | | 1 | 156 | 6 |
| 9 | NESTED LOOPS | | 1 | 143 | 6 |
| 10 | NESTED LOOPS OUTER | | 1 | 117 | 5 |
|* 11 | HASH JOIN | | 1 | 104 | 5 |
| 12 | NESTED LOOPS | | 1 | 52 | 2 |
|* 13 | TABLE ACCESS FULL | TAB3 | 1 | 39 | 2 |
|* 14 | INDEX UNIQUE SCAN | (PK_TAB4) | 1 | 13 | |
| 15 | TABLE ACCESS FULL | TAB5 | 82 | 4264 | 2 |
| 16 | VIEW PUSHED PREDICATE | View3 | 1 | 13 | |
| 17 | NESTED LOOPS | | 1 | 52 | 2 |
| 18 | NESTED LOOPS | | 1 | 39 | 2 |
|* 19 | INDEX UNIQUE SCAN | (PK_TAB6) | 1 | 13 | 1 |
|* 20 | INDEX RANGE SCAN | (PK_TAB7) | 1 | 26 | 1 |
|* 21 | INDEX UNIQUE SCAN | (PK_TAB8) | 1 | 13 | |
| 22 | TABLE ACCESS BY INDEX ROWID| TAB9 | 3 | 78 | 1 |
|* 23 | INDEX UNIQUE SCAN | (PK_TAB9) | 1 | | |
|* 24 | INDEX UNIQUE SCAN | (PK_TAB10)| 1 | 13 | |
| 25 | BUFFER SORT | | 1 | 115 | 9 |
| 26 | TABLE ACCESS BY INDEX ROWID | TAB2 | 1 | 115 | 1 |
|* 27 | INDEX RANGE SCAN | (TAB2_IDX2)| 1 | | |
|* 28 | TABLE ACCESS BY INDEX ROWID | TAB1 | 12 | 25224 | 1 |
|* 29 | INDEX UNIQUE SCAN | (PK_TAB1) | 1 | | |
Predicate Information (identified by operation id):
1 - filter(ROWNUM<=3)
3 - filter(ROWNUM<=3)
11 - access("TAB5"."PATH_ID"="TAB4"."PATH_ID")
13 - filter("TAB3"."AUTH_GROUP_ID"<>(-1) AND ("TAB3"."AUTH_GROUP_ID"=0 OR "TAB3"."AUTH_GROUP_ID"=1))
14 - access("TAB3"."PATH_ID"="TAB4"."PATH_ID")
19 - access("TAB5"."DOMAIN_ID"="TAB6"."DOMAIN_ID")
20 - access("TAB6"."DOMAIN_ID"="TAB7"."DOMAIN_ID")
21 - access("TAB7"."RULE_ID"="TAB8"."RULE_ID")
23 - access("TAB9"."POLICY_ID"="TAB5"."POLICY_ID")
24 - access("TAB9"."ASSOCIATED_FORM_ID"="TAB10"."FORM_ID")
27 - access("TAB2"."CERT_SERIAL_NUM"=24293)
28 - filter("View2"."POLICY_ID"="TAB1"."POLICY_ID")
29 - access("TAB1"."TRANSACTION_ID"="TAB2"."TRANSACTION_ID")
Note: cpu costing is off
54 rows selected.
Elapsed: 00:00:01.81
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 COLLECTION ITERATOR (PICKLER FETCH) OF 'DISPLAY'
Statistics
39 recursive calls
0 db block gets
629 consistent gets
0 physical reads
104 redo size
5169 bytes sent via SQL*Net to client
405 bytes received via SQL*Net from client
5 SQL*Net roundtrips to/from client
31 sorts (memory)
0 sorts (disk)
54 rows processed
2) Execution Plan for VIEW1 <<-- With ORDER BY" clause and table alias (order by TAB2.transaction_id)
SQL> explain plan for SELECT TO_CHAR(QT.TRANSACTION_ID), QT.POLICY_ID, QT.REQUEST_TYPE
2 FROM <VIEW1> QT WHERE QT.CERT_SERIAL_NUM=30003 AND
3 (QT.AUTH_GROUP_ID=0 OR QT.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
4 BY TRANSACTION_ID ASC
5 /
Explained.
Elapsed: 00:00:10.20
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 3 | 195 | 14 |
| 1 | SORT ORDER BY | | 3 | 195 | 14 |
|* 2 | COUNT STOPKEY | | | | |
| 3 | VIEW | VIEW1 | 17 | 1105 | 13 |
| 4 | NESTED LOOPS | | 17 | 38573 | 13 |
| 5 | MERGE JOIN CARTESIAN | | 1 | 167 | 12 |
|* 6 | TABLE ACCESS BY INDEX ROWID | TAB2 | 1 | 115 | 4 |
| 7 | INDEX FULL SCAN | (TAB2_IDX) | 94 | | 1 |
| 8 | BUFFER SORT | | 1 | 52 | 8 |
| 9 | VIEW | VIEW2 | 1 | 52 | 8 |
| 10 | SORT UNIQUE | | 1 | 156 | 8 |
| 11 | NESTED LOOPS | | 1 | 156 | 6 |
| 12 | NESTED LOOPS | | 1 | 143 | 6 |
| 13 | NESTED LOOPS OUTER | | 1 | 117 | 5 |
|* 14 | HASH JOIN | | 1 | 104 | 5 |
| 15 | NESTED LOOPS | | 1 | 52 | 2 |
|* 16 | TABLE ACCESS FULL | TAB3 | 1 | 39 | 2 |
|* 17 | INDEX UNIQUE SCAN | (PK_TAB4) | 1 | 13 | |
| 18 | TABLE ACCESS FULL | TAB5 | 82 | 4264 | 2 |
| 19 | VIEW PUSHED PREDICATE | View3 | 1 | 13 | |
| 20 | NESTED LOOPS | | 1 | 52 | 2 |
| 21 | NESTED LOOPS | | 1 | 39 | 2 |
|* 22 | INDEX UNIQUE SCAN | (PK_TAB6) | 1 | 13 | 1 |
|* 23 | INDEX RANGE SCAN | (PK_TAB7) | 1 | 26 | 1 |
|* 24 | INDEX UNIQUE SCAN | (PK_TAB8) | 1 | 13 | |
| 25 | TABLE ACCESS BY INDEX ROWID| TAB9 | 3 | 78 | 1 |
|* 26 | INDEX UNIQUE SCAN | (PK_TAB9) | 1 | | |
|* 27 | INDEX UNIQUE SCAN | (PK_TAB10) | 1 | 13 | |
|* 28 | TABLE ACCESS BY INDEX ROWID | TAB1 | 12 | 25224 | 1 |
|* 29 | INDEX UNIQUE SCAN | (PK_TAB1) | 1 | | |
Predicate Information (identified by operation id):
2 - filter(ROWNUM<=3)
6 - filter("TAB2"."CERT_SERIAL_NUM"=30003)
14 - access("TAB5"."PATH_ID"="TAB4"."PATH_ID")
16 - filter("TAB3"."AUTH_GROUP_ID"<>(-1) AND ("TAB3"."AUTH_GROUP_ID"=0 OR "TAB3"."AUTH_GROUP_ID"=1))
17 - access("TAB3"."PATH_ID"="TAB4"."PATH_ID")
22 - access("TAB5"."DOMAIN_ID"="TAB6"."DOMAIN_ID")
23 - access("TAB6"."DOMAIN_ID"="TAB7"."DOMAIN_ID")
24 - access("TAB7"."RULE_ID"="TAB8"."RULE_ID")
26 - access("TAB9"."POLICY_ID"="TAB5"."POLICY_ID")
27 - access("TAB9"."ASSOCIATED_FORM_ID"="TAB10"."FORM_ID")
28 - filter("VIEW2"."POLICY_ID"="TAB1"."POLICY_ID")
29 - access("TAB1"."TRANSACTION_ID"="TAB2"."TRANSACTION_ID")
Note: cpu costing is off
53 rows selected.
Elapsed: 00:00:08.29
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 COLLECTION ITERATOR (PICKLER FETCH) OF 'DISPLAY'
Statistics
1079 recursive calls
0 db block gets
597 consistent gets
21 physical reads
0 redo size
5177 bytes sent via SQL*Net to client
405 bytes received via SQL*Net from client
5 SQL*Net roundtrips to/from client
63 sorts (memory)
0 sorts (disk)
53 rows processed
3) Execution Plan for VIEW1 <<-- Without any "ORDER BY" clause
SQL> explain plan for SELECT TO_CHAR(QT.TRANSACTION_ID), QT.POLICY_ID, QT.REQUEST_TYPE
2 FROM <VIEW1> QT WHERE QT.CERT_SERIAL_NUM=30003 AND
3 (QT.AUTH_GROUP_ID=0 OR QT.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
4 BY TRANSACTION_ID ASC
5 /
Explained.
Elapsed: 00:00:10.20
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 3 | 213 | 11 |
| 1 | SORT ORDER BY | | 3 | 213 | 11 |
|* 2 | COUNT STOPKEY | | | | |
| 3 | NESTED LOOPS | | 17 | 1207 | 10 |
| 4 | MERGE JOIN CARTESIAN | | 1 | 32 | 9 |
| 5 | VIEW | VIEW2 | 1 | 26 | 8 |
| 6 | SORT UNIQUE | | 1 | 156 | 8 |
| 7 | NESTED LOOPS | | 1 | 156 | 6 |
| 8 | NESTED LOOPS | | 1 | 143 | 6 |
| 9 | NESTED LOOPS OUTER | | 1 | 117 | 5 |
|* 10 | HASH JOIN | | 1 | 104 | 5 |
| 11 | NESTED LOOPS | | 1 | 52 | 2 |
|* 12 | TABLE ACCESS FULL | TAB3 | 1 | 39 | 2 |
|* 13 | INDEX UNIQUE SCAN | PK_TAB4 | 1 | 13 | |
| 14 | TABLE ACCESS FULL | TAB5 | 82 | 4264 | 2 |
| 15 | VIEW PUSHED PREDICATE | VIEW3 | 1 | 13 | |
| 16 | NESTED LOOPS | | 1 | 52 | 2 |
| 17 | NESTED LOOPS | | 1 | 39 | 2 |
|* 18 | INDEX UNIQUE SCAN | PK_TAB6 | 1 | 13 | 1 |
|* 19 | INDEX RANGE SCAN | PK_TAB7 | 1 | 26 | 1 |
|* 20 | INDEX UNIQUE SCAN | PK_TAB8 | 1 | 13 | |
| 21 | TABLE ACCESS BY INDEX ROWID| TAB9 | 3 | 78 | 1 |
|* 22 | INDEX UNIQUE SCAN | PK_TAB9 | 1 | | |
|* 23 | INDEX UNIQUE SCAN | PK_TAB10 | 1 | 13 | |
| 24 | BUFFER SORT | | 1 | 6 | 9 |
| 25 | TABLE ACCESS BY INDEX ROWID | TAB2 | 1 | 6 | 1 |
|* 26 | INDEX RANGE SCAN | TAB2_IDX2 | 1 | | |
|* 27 | TABLE ACCESS BY INDEX ROWID | TAB1 | 12 | 468 | 1 |
|* 28 | INDEX UNIQUE SCAN | PK_TAB1 | 1 | | |
Predicate Information (identified by operation id):
2 - filter(ROWNUM<=3)
10 - access("TAB5"."PATH_ID"="TAB4"."PATH_ID")
12 - filter("TAB3"."AUTH_GROUP_ID"<>(-1) AND ("TAB3"."AUTH_GROUP_ID"=0 OR "TAB3"."AUTH_GROUP_ID"=1))
13 - access("TAB3"."PATH_ID"="TAB4"."PATH_ID")
18 - access("TAB5"."DOMAIN_ID"="TAB6"."DOMAIN_ID")
19 - access("TAB6"."DOMAIN_ID"="TAB7"."DOMAIN_ID")
20 - access("TAB7"."RULE_ID"="TAB8"."RULE_ID")
22 - access("TAB9"."POLICY_ID"="TAB5"."POLICY_ID")
23 - access("TAB9"."ASSOCIATED_FORM_ID"="TAB10"."FORM_ID")
26 - access("TAB2"."CERT_SERIAL_NUM"=1022)
27 - filter("VIEW2"."POLICY_ID"="TAB1"."POLICY_ID")
28 - access("TAB1"."TRANSACTION_ID"="TAB2"."TRANSACTION_ID")
Note: cpu costing is off
52 rows selected.
Elapsed: 00:00:03.37
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 COLLECTION ITERATOR (PICKLER FETCH) OF 'DISPLAY'
Statistics
38 recursive calls
0 db block gets
287 consistent gets
0 physical reads
0 redo size
5006 bytes sent via SQL*Net to client
405 bytes received via SQL*Net from client
5 SQL*Net roundtrips to/from client
29 sorts (memory)
0 sorts (disk)
52 rows processed -
Indexes for group by query on table with 5million records
Hi,
Here is my query which is taking ages to run :
SELECT approved.budgetReferenceno
, approved.projects
, approved.allocations
, rptgen4
, financialyear
, cashclass
, SUM(nvl(approved.FullYear,0)) as FullYear
FROM approved
JOIN rpt_entity ON rpt_entity.level0 = approved.entity
JOIN cashclasses ON accountcode = approved.account
where budgetreferenceno = refno
and
entity in (
(select Level0 from rpt_entity where
( entityparent in (select * from table(split(userid))) or rptgen5 in (select * from table(split(userid))) ) )
and
ccs in (select level0 from rpt_ccs where rptgen4 in (select * from table(split(userid)))) or
ccs in (select level0 from rpt_ccs where rptgen5 in (select * from table(split(userid)))) or
ccs in (select level0 from rpt_ccs where rptgen6 in (select * from table(split(userid)))) or
ccs in (select level0 from rpt_ccs where rptgen7 in (select * from table(split(userid))) ) or
ccs in (select distinct(substr(column_value,2,length(column_value)-2)) from table(split_comma(userid)) )
GROUP BY approved.budgetReferenceno
, approved.projects
, approved.allocations
, rptgen4
, financialyear
, cashclass
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 4074481161
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 31234 | 3660K| | 86141 (1)| 00:17:14 |
| 1 | HASH GROUP BY | | 31234 | 3660K| 17M| 86141 (1)| 00:17:14 |
|* 2 | FILTER | | | | | | |
|* 3 | HASH JOIN | | 138K| 15M| | 82427 (1)| 00:16:30 |
| 4 | TABLE ACCESS FULL | CASHCLASSES | 2875 | 48875 | | 5 (0)| 00:00:01 |
|* 5 | HASH JOIN | | 138K| 13M| | 82420 (1)| 00:16:30 |
PLAN_TABLE_OUTPUT
| 6 | TABLE ACCESS FULL | RPT_entity | 725 | 10875 | | 11 (0)| 00:00:01 |
|* 7 | HASH JOIN RIGHT SEMI | | 138K| 11M| | 82408 (1)| 00:16:29 |
| 8 | VIEW | VW_NSO_1 | 71 | 568 | | 11 (0)| 00:00:01 |
|* 9 | FILTER | | | | | | |
| 10 | TABLE ACCESS FULL | RPT_entity | 725 | 17400 | | 11 (0)| 00:00:01 |
|* 11 | COLLECTION ITERATOR PICKLER FETCH| SPLIT | | | | | |
|* 12 | COLLECTION ITERATOR PICKLER FETCH| SPLIT | | | | | |
|* 13 | TABLE ACCESS FULL | approved | 1170K| 89M| | 82389 (1)| 00:16:29 |
| 14 | NESTED LOOPS | | 1 | 18 | | 46 (0)| 00:00:01 |
| 15 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
|* 16 | INDEX RANGE SCAN | CC_INDEX1 | 1 | 16 | | 1 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
| 17 | NESTED LOOPS | | 2 | 46 | | 51 (2)| 00:00:01 |
|* 18 | INDEX FAST FULL SCAN | CC_INDEX2 | 1 | 21 | | 46 (3)| 00:00:01 |
|* 19 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
| 20 | NESTED LOOPS | | 1 | 24 | | 52 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID | RPT_ccs | 1 | 22 | | 46 (0)| 00:00:01 |
|* 22 | INDEX SKIP SCAN | CC_INDEX1 | 1 | | | 45 (0)| 00:00:01 |
|* 23 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
| 24 | NESTED LOOPS | | 2 | 50 | | 60 (0)| 00:00:01 |
| 25 | TABLE ACCESS BY INDEX ROWID | RPT_ccs | 1 | 23 | | 46 (0)| 00:00:01 |
|* 26 | INDEX SKIP SCAN | CC_INDEX1 | 1 | | | 45 (0)| 00:00:01 |
|* 27 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
PLAN_TABLE_OUTPUT
|* 28 | COLLECTION ITERATOR PICKLER FETCH | SPLIT_COMMA | | | | | |
Predicate Information (identified by operation id):
2 - filter( EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
"LEVEL0"=:B1 AND "RPTGEN4"=VALUE(KOKBF$)) OR EXISTS (SELECT 0 FROM "RPT_ccs"
"RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN5"=VALUE(KOKBF$) AND "LEVEL0"=:B2) OR EXISTS (SELECT 0
FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN6"=VALUE(KOKBF$) AND "LEVEL0"=:B3)
OR EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
PLAN_TABLE_OUTPUT
"RPTGEN7"=VALUE(KOKBF$) AND "LEVEL0"=:B4) OR EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE
SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B5))
3 - access("ACCOUNTCODE"="approved"."ACCOUNT")
5 - access("RPT_entity"."LEVEL0"="approved"."entity")
7 - access("approved"."entity"="LEVEL0")
9 - filter( EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B1) OR EXISTS (SELECT 0 FROM
TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B2))
11 - filter(VALUE(KOKBF$)=:B1)
12 - filter(VALUE(KOKBF$)=:B1)
13 - filter("approved"."BUDGETREFERENCENO"='BASE')
16 - access("RPTGEN4"=VALUE(KOKBF$) AND "LEVEL0"=:B1)
PLAN_TABLE_OUTPUT
18 - filter("LEVEL0"=:B1)
19 - filter("RPTGEN5"=VALUE(KOKBF$))
22 - access("LEVEL0"=:B1)
filter("LEVEL0"=:B1)
23 - filter("RPTGEN6"=VALUE(KOKBF$))
26 - access("LEVEL0"=:B1)
filter("LEVEL0"=:B1)
27 - filter("RPTGEN7"=VALUE(KOKBF$))
28 - filter(SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B1)
64 rows selected.
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionThe table has 28 columns none indexed the columns mentioned here have non unique values.
The table approved has more than 10million records and the query is taking a huge time.
The query first tries to restrict the search to only valid entities and cc (already indexed and working fine).
The cardinality of allocations, projects is around 1000, entity is 3000, and cc is around 50,000, reference number = 2000, financialyear = 4
Please suggest which index would be best to use on these columns given that there will no updations but frequent insertions.
If nothing else works than I will need to change it to pre aggregated data for overnight run .
Thanks,
Neetesh
Edited by: user13312817 on Nov 16, 2011 11:05 AM
Edited by: user13312817 on Nov 16, 2011 11:36 AM
Edited by: user13312817 on Nov 16, 2011 11:38 AM
Edited by: user13312817 on Nov 16, 2011 12:02 PMHello Adam,
Tried this but still not much of a difference.
create index test_index on approved (budgetreferenceno,projects,allocations,financialyear,entity,ccs,FullYear) compress 6;
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 2463060356
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25030 | 4644K| | 70852 (1)| 00:14:11 |
| 1 | TABLE ACCESS BY INDEX ROWID | FEGEN4 | 1 | 13 | | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | INDEX1 | 1 | | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | CASHCLASSES | 1 | 17 | | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | CASHCLASSES_PK | 1 | | | 1 (0)| 00:00:01 |
| 5 | HASH GROUP BY | | 25030 | 4644K| 21M| 70852 (1)| 00:14:11 |
PLAN_TABLE_OUTPUT
| 6 | VIEW | | 109K| 19M| | 68578 (1)| 00:13:43 |
|* 7 | FILTER | | | | | | |
|* 8 | HASH JOIN RIGHT SEMI | | 484K| 99M| | 68578 (1)| 00:13:43 |
| 9 | VIEW | VW_NSO_1 | 71 | 7242 | | 11 (0)| 00:00:01 |
|* 10 | FILTER | | | | | | |
| 11 | TABLE ACCESS FULL | RPT_entity | 725 | 17400 | | 11 (0)| 00:00:01 |
|* 12 | COLLECTION ITERATOR PICKLER FETCH| SPLIT | | | | | |
|* 13 | COLLECTION ITERATOR PICKLER FETCH| SPLIT | | | | | |
|* 14 | TABLE ACCESS FULL | approved | 982K| 106M| | 68560 (1)| 00:13:43 |
| 15 | NESTED LOOPS | | 1 | 18 | | 46 (0)| 00:00:01 |
| 16 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
PLAN_TABLE_OUTPUT
|* 17 | INDEX RANGE SCAN | CC_INDEX1 | 1 | 16 | | 1 (0)| 00:00:01 |
| 18 | NESTED LOOPS | | 2 | 46 | | 51 (2)| 00:00:01 |
|* 19 | INDEX FAST FULL SCAN | CC_INDEX2 | 1 | 21 | | 46 (3)| 00:00:01 |
|* 20 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
| 21 | NESTED LOOPS | | 1 | 24 | | 52 (0)| 00:00:01 |
| 22 | TABLE ACCESS BY INDEX ROWID | RPT_ccs | 1 | 22 | | 46 (0)| 00:00:01 |
|* 23 | INDEX SKIP SCAN | CC_INDEX1 | 1 | | | 45 (0)| 00:00:01 |
|* 24 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
| 25 | NESTED LOOPS | | 2 | 50 | | 60 (0)| 00:00:01 |
| 26 | TABLE ACCESS BY INDEX ROWID | RPT_ccs | 1 | 23 | | 46 (0)| 00:00:01 |
|* 27 | INDEX SKIP SCAN | CC_INDEX1 | 1 | | | 45 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
|* 28 | COLLECTION ITERATOR PICKLER FETCH | SPLIT | | | | | |
|* 29 | COLLECTION ITERATOR PICKLER FETCH | SPLIT_COMMA | | | | | |
Predicate Information (identified by operation id):
2 - access("LEVEL0"=:B1)
4 - access("ACCOUNTCODE"=:B1)
7 - filter( EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
"LEVEL0"=:B1 AND "RPTGEN4"=VALUE(KOKBF$)) OR EXISTS (SELECT 0 FROM "RPT_ccs"
PLAN_TABLE_OUTPUT
"RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN5"=VALUE(KOKBF$) AND "LEVEL0"=:B2) OR EXISTS (SELECT 0
FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE "RPTGEN6"=VALUE(KOKBF$) AND "LEVEL0"=:B3)
OR EXISTS (SELECT 0 FROM "RPT_ccs" "RPT_ccs",TABLE() "KOKBF$" WHERE
"RPTGEN7"=VALUE(KOKBF$) AND "LEVEL0"=:B4) OR EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE
SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B5))
8 - access("entity"="LEVEL0")
10 - filter( EXISTS (SELECT 0 FROM TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B1) OR EXISTS (SELECT 0 FROM
TABLE() "KOKBF$" WHERE VALUE(KOKBF$)=:B2))
12 - filter(VALUE(KOKBF$)=:B1)
13 - filter(VALUE(KOKBF$)=:B1)
14 - filter("BUDGETREFERENCENO"='BASE')
PLAN_TABLE_OUTPUT
17 - access("RPTGEN4"=VALUE(KOKBF$) AND "LEVEL0"=:B1)
19 - filter("LEVEL0"=:B1)
20 - filter("RPTGEN5"=VALUE(KOKBF$))
23 - access("LEVEL0"=:B1)
filter("LEVEL0"=:B1)
24 - filter("RPTGEN6"=VALUE(KOKBF$))
27 - access("LEVEL0"=:B1)
filter("LEVEL0"=:B1)
28 - filter("RPTGEN7"=VALUE(KOKBF$))
29 - filter(SUBSTR(VALUE(KOKBF$),2,LENGTH(VALUE(KOKBF$))-2)=:B1)
PLAN_TABLE_OUTPUT
Note
- dynamic sampling used for this statement
69 rows selected.Thanks,
Neetesh
Edited by: user13312817 on Nov 17, 2011 7:04 AM -
How to improve performance of a query that is based on an xmltype table
Dear Friends,
I have a query that is pulling records from an xmltype table with 9000 rows and it is running very slow.
I am using XMLTABLE command to retreive the rows. It is taking upto 30 minutes to finish.
Would you be able to suggest how I can make it faster. Thanks.
Below is the query.....
INSERT INTO temp_sap_po_receipt_history_t
(po_number, po_line_number, doc_year,
material_doc, material_doc_item, quantity, sap_ref_doc_no_long,
reference_doc, movement_type_code,
sap_ref_doc_no, posting_date, entry_date, entry_time, hist_type)
SELECT :pin_po_number po_number,
b.po_line_number, b.doc_year,
b.material_doc, b.material_doc_item, b.quantity, b.sap_ref_doc_no_long,
b.reference_doc, b.movement_type_code,
b.sap_ref_doc_no, to_date(b.posting_date,'rrrr-mm-dd'),
to_date(b.entry_date,'rrrr-mm-dd'), b.entry_time, b.hist_type
FROM temp_xml t,
XMLTABLE(XMLNAMESPACES('urn:sap-com:document:sap:rfc:functions' AS "n0"),
'/n0:BAPI_PO_GETDETAIL1Response/POHISTORY/item'
PASSING t.object_value
COLUMNS PO_LINE_NUMBER VARCHAR2(20) PATH 'PO_ITEM',
DOC_YEAR varchar2(4) PATH 'DOC_YEAR',
MATERIAL_DOC varchar2(30) PATH 'MAT_DOC',
MATERIAL_DOC_ITEM VARCHAR2(10) PATH 'MATDOC_ITEM',
QUANTITY NUMBER(20,6) PATH 'QUANTITY',
SAP_REF_DOC_NO_LONG VARCHAR2(20) PATH 'REF_DOC_NO_LONG',
REFERENCE_DOC VARCHAR2(20) PATH 'REF_DOC',
MOVEMENT_TYPE_CODE VARCHAR2(4) PATH 'MOVE_TYPE',
SAP_REF_DOC_NO VARCHAR2(20) PATH 'REF_DOC_NO',
POSTING_DATE VARCHAR2(10) PATH 'PSTNG_DATE',
ENTRY_DATE VARCHAR2(10) PATH 'ENTRY_DATE',
ENTRY_TIME VARCHAR2(8) PATH 'ENTRY_TIME',
HIST_TYPE VARCHAR2(5) PATH 'HIST_TYPE') b;Based on response from mdrake on this thread:
Re: XML file processing into oracle
For large XML's, you can speed up the processing of XMLTABLE by using a registered schema...
declare
SCHEMAURL VARCHAR2(256) := 'http://xmlns.example.org/xsd/testcase.xsd';
XMLSCHEMA VARCHAR2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="cust_order" type="cust_orderType" xdb:defaultTable="CUST_ORDER_TBL"/>
<xs:complexType name="groupType" xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="item" type="itemType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:byte" use="required"/>
</xs:complexType>
<xs:complexType name="itemType" xdb:maintainDOM="false">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:short" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="cust_orderType" xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="group" type="groupType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="cust_id" type="xs:short" use="required"/>
</xs:complexType>
</xs:schema>';
INSTANCE CLOB :=
'<cust_order cust_id="12345">
<group id="1">
<item id="1" name="Standard Mouse">100</item>
<item id="2" name="Keyboard">100</item>
<item id="3" name="Memory Module 2Gb">200</item>
<item id="4" name="Processor 3Ghz">25</item>
<item id="5" name="Processor 2.4Ghz">75</item>
</group>
<group id="2">
<item id="1" name="Graphics Tablet">15</item>
<item id="2" name="Keyboard">15</item>
<item id="3" name="Memory Module 4Gb">15</item>
<item id="4" name="Processor Quad Core 2.8Ghz">15</item>
</group>
<group id="3">
<item id="1" name="Optical Mouse">5</item>
<item id="2" name="Ergo Keyboard">5</item>
<item id="3" name="Memory Module 2Gb">10</item>
<item id="4" name="Processor Dual Core 2.4Ghz">5</item>
<item id="5" name="Dual Output Graphics Card">5</item>
<item id="6" name="28inch LED Monitor">10</item>
<item id="7" name="Webcam">5</item>
<item id="8" name="A3 1200dpi Laser Printer">2</item>
</group>
</cust_order>';
begin
dbms_xmlschema.registerSchema
schemaurl => SCHEMAURL
,schemadoc => XMLSCHEMA
,local => TRUE
,genTypes => TRUE
,genBean => FALSE
,genTables => TRUE
,ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
execute immediate 'insert into CUST_ORDER_TBL values (XMLTYPE(:INSTANCE))' using INSTANCE;
end;
SQL> desc CUST_ORDER_TBL
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.org/xsd/testcase.xsd" Element "cust_order") STORAGE Object-relational TYPE "cust_orderType222_T"
SQL> set autotrace on explain
SQL> set pages 60 lines 164 heading on
SQL> col cust_id format a8
SQL> select extract(object_value,'/cust_order/@cust_id') as cust_id
2 ,grp.id as group_id, itm.id as item_id, itm.inm as item_name, itm.qty as item_qty
3 from CUST_ORDER_TBL
4 ,XMLTABLE('/cust_order/group'
5 passing object_value
6 columns id number path '@id'
7 ,item xmltype path 'item'
8 ) grp
9 ,XMLTABLE('/item'
10 passing grp.item
11 columns id number path '@id'
12 ,inm varchar2(30) path '@name'
13 ,qty number path '.'
14 ) itm
15 /
CUST_ID GROUP_ID ITEM_ID ITEM_NAME ITEM_QTY
12345 1 1 Standard Mouse 100
12345 1 2 Keyboard 100
12345 1 3 Memory Module 2Gb 200
12345 1 4 Processor 3Ghz 25
12345 1 5 Processor 2.4Ghz 75
12345 2 1 Graphics Tablet 15
12345 2 2 Keyboard 15
12345 2 3 Memory Module 4Gb 15
12345 2 4 Processor Quad Core 2.8Ghz 15
12345 3 1 Optical Mouse 5
12345 3 2 Ergo Keyboard 5
12345 3 3 Memory Module 2Gb 10
12345 3 4 Processor Dual Core 2.4Ghz 5
12345 3 5 Dual Output Graphics Card 5
12345 3 6 28inch LED Monitor 10
12345 3 7 Webcam 5
12345 3 8 A3 1200dpi Laser Printer 2
17 rows selected.Need at least 10.2.0.3 for performance i.e. to avoid COLLECTION ITERATOR PICKLER FETCH in execution plan...
On 10.2.0.1:
Execution Plan
Plan hash value: 3741473841
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 24504 | 89M| 873 (1)| 00:00:11 |
| 1 | NESTED LOOPS | | 24504 | 89M| 873 (1)| 00:00:11 |
| 2 | NESTED LOOPS | | 3 | 11460 | 805 (1)| 00:00:10 |
| 3 | TABLE ACCESS FULL | CUST_ORDER_TBL | 1 | 3777 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | SYS_IOT_TOP_774117 | 3 | 129 | 1 (0)| 00:00:01 |
| 5 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | |
Predicate Information (identified by operation id):
4 - access("NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statementOn 10.2.0.3:
Execution Plan
Plan hash value: 1048233240
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 17 | 132K| 839 (0)| 00:00:11 |
| 1 | NESTED LOOPS | | 17 | 132K| 839 (0)| 00:00:11 |
| 2 | MERGE JOIN CARTESIAN | | 17 | 131K| 805 (0)| 00:00:10 |
| 3 | TABLE ACCESS FULL | CUST_ORDER_TBL | 1 | 3781 | 3 (0)| 00:00:01 |
| 4 | BUFFER SORT | | 17 | 70839 | 802 (0)| 00:00:10 |
|* 5 | INDEX FAST FULL SCAN| SYS_IOT_TOP_56154 | 17 | 70839 | 802 (0)| 00:00:10 |
|* 6 | INDEX UNIQUE SCAN | SYS_IOT_TOP_56152 | 1 | 43 | 2 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | SYS_C006701 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
6 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
w5Ysl6x9w=="."SYS_NC0000600007$")
filter("SYS_NC_TYPEID$" IS NOT NULL AND
"NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
7 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
w5Ysl6x9w=="."SYS_NC0000600007$")
Note
- dynamic sampling used for this statement----------------------------------------------------------------------------------------------------------
-- CLEAN UP
DROP TABLE CUST_ORDER_TBL purge;
exec dbms_xmlschema.deleteschema('http://xmlns.example.org/xsd/testcase.xsd'); -
Query - Performance - in operator
Hi All,
I apologize for a lengthy posting.
I have a problem in performance of a Query.
When I use static value in a in-list as given in Query1, it is faster and the Logical I/O is very less.
But the values in the list are dynamic, So I tried two Methods
Method 1
CREATE OR REPLACE TYPE PF_TY_TBL_NUM AS TABLE OF NUMBER;
and created a function as follows...
CREATE OR REPLACE FUNCTION PF_FN_GET_NUM_LIST(PARAM_STR VARCHAR2) RETURN PF_TY_TBL_NUM
AS
V_STRINGS long default PARAM_STR || ',';
V_INDEX number;
V_DATA PF_TY_TBL_NUM := PF_TY_TBL_NUM();
BEGIN
LOOP
V_INDEX := INSTR(V_STRINGS, ',' );
EXIT WHEN (NVL(V_INDEX,0) = 0);
V_DATA.extend;
V_DATA( V_DATA.count ) := ltrim(rtrim(substr(V_STRINGS,1,V_INDEX-1)));
V_STRINGS := SUBSTR( V_STRINGS, V_INDEX+1 );
END LOOP;
RETURN V_DATA;
END PF_FN_GET_NUM_LIST;
Query and result for this is given in Query2 -- You can Notice that the index for the 2nd table is not used and the Consistent gets is higher than the Query1
Method 2
Is I have created a temporary table and inserted values into that and used the table in the exist clause.
Query and result for this is given in Query2 -- You can Notice that the index for the 2nd table is not used and the Consistent gets is higher than the Query1
Can Anyone suggest me on this.
Query 1:
SELECT PR.pr_id,
sp.sp_class_destinatario,
SP.sp_sospesa,
sp.sp_id_destinatario,
IV.in_id_mittente,
IV.in_oggetto,
IV.in_data_spedizione,
PR.pr_id_soggetto,
PR.PR_NUMERO_PRATICA,
PR.pr_id_utente_presentatore
FROM PF_TR_INVIO IV, PF_TR_SITUAZIONE_PRATICA SP, PF_TR_PRATICA PR
WHERE (((SP.SP_CLASS_DESTINATARIO = 10) AND (SP.SP_ID_DESTINATARIO = 1260)) OR
((SP.SP_CLASS_DESTINATARIO = 20) AND
(SP.SP_ID_DESTINATARIO IN
('7', '2', '17', '333', '349', '501', '1', '320', '414', '406',
'1889', '3018', '1364', '1140', '10', '3052', '71'))) OR
((SP.SP_CLASS_DESTINATARIO = 30) AND (SP.SP_ID_DESTINATARIO = 420)))
AND (SP.SP_ID_ULTIMO_INVIO = IV.IN_ID)
AND (SP.SP_ID_PRATICA = PR.PR_ID)
ORDER BY IV.IN_ID,
PR.PR_NUMERO_PRATICA
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=63 Card=4 Bytes=276)
1 0 SORT (ORDER BY) (Cost=63 Card=4 Bytes=276)
2 1 CONCATENATION
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_INVIO' (Cost=1
Card=1 Bytes=22)
4 3 NESTED LOOPS (Cost=5 Card=1 Bytes=69)
5 4 NESTED LOOPS (Cost=4 Card=1 Bytes=47)
6 5 INLIST ITERATOR
7 6 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_SITUAZ
IONE_PRATICA' (Cost=3 Card=1 Bytes=15)
8 7 INDEX (RANGE SCAN) OF 'PF_SP_IN_DESTINATARIO
' (NON-UNIQUE) (Cost=2 Card=1)
9 5 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_PRATICA'
(Cost=1 Card=1 Bytes=32)
10 9 INDEX (RANGE SCAN) OF 'PF_PR_IN_ID' (NON-UNIQU
E)
11 4 INDEX (RANGE SCAN) OF 'PF_IN_IN_ID' (NON-UNIQUE)
12 2 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_INVIO' (Cost=1
Card=1 Bytes=22)
13 12 NESTED LOOPS (Cost=5 Card=1 Bytes=69)
14 13 NESTED LOOPS (Cost=4 Card=1 Bytes=47)
15 14 INLIST ITERATOR
16 15 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_SITUAZ
IONE_PRATICA' (Cost=3 Card=1 Bytes=15)
17 16 INDEX (RANGE SCAN) OF 'PF_SP_IN_DESTINATARIO
' (NON-UNIQUE) (Cost=2 Card=1)
18 14 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_PRATICA'
(Cost=1 Card=1 Bytes=32)
19 18 INDEX (RANGE SCAN) OF 'PF_PR_IN_ID' (NON-UNIQU
E)
20 13 INDEX (RANGE SCAN) OF 'PF_IN_IN_ID' (NON-UNIQUE)
Statistics
115 recursive calls
0 db block gets
121 consistent gets
42 physical reads
0 redo size
1176 bytes sent via SQL*Net to client
277 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
13 rows processed
Query2
SELECT PR.pr_id,
sp.sp_class_destinatario,
SP.sp_sospesa,
sp.sp_id_destinatario,
IV.in_id_mittente,
IV.in_oggetto,
IV.in_data_spedizione,
PR.pr_id_soggetto,
PR.PR_NUMERO_PRATICA,
PR.pr_id_utente_presentatore
FROM PF_TR_INVIO IV,
PF_TR_SITUAZIONE_PRATICA SP,
PF_TR_PRATICA PR
WHERE (((SP.SP_CLASS_DESTINATARIO = 10) AND
(SP.SP_ID_DESTINATARIO = 1260)) OR
((SP.SP_CLASS_DESTINATARIO = 20) AND
(SP.SP_ID_DESTINATARIO IN
(SELECT column_value
FROM TABLE(CAST(PF_FN_GET_NUM_LIST('7,2,17,333,349,501,1,320,414,406,1889,3018,1364,1140,10,3052,71') AS
PF_TY_TBL_NUM))))) OR
((SP.SP_CLASS_DESTINATARIO = 30) AND
(SP.SP_ID_DESTINATARIO = 420)))
AND (SP.SP_ID_ULTIMO_INVIO = IV.IN_ID)
AND (SP.SP_ID_PRATICA = PR.PR_ID)
ORDER BY IV.IN_ID,
PR.PR_NUMERO_PRATICA
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=80 Card=11 Bytes=759
1 0 SORT (ORDER BY) (Cost=80 Card=11 Bytes=759)
2 1 FILTER
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_INVIO' (Cost=1
Card=1 Bytes=22)
4 3 NESTED LOOPS (Cost=33 Card=11 Bytes=759)
5 4 NESTED LOOPS (Cost=22 Card=11 Bytes=517)
6 5 TABLE ACCESS (FULL) OF 'PF_TR_SITUAZIONE_PRATICA
' (Cost=11 Card=11 Bytes=165)
7 5 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_PRATICA'
(Cost=1 Card=1 Bytes=32)
8 7 INDEX (RANGE SCAN) OF 'PF_PR_IN_ID' (NON-UNIQU
E)
9 4 INDEX (RANGE SCAN) OF 'PF_IN_IN_ID' (NON-UNIQUE)
10 2 COLLECTION ITERATOR (PICKLER FETCH) OF 'PF_FN_GET_NUM_
LIST'
Statistics
205 recursive calls
0 db block gets
7285 consistent gets
203 physical reads
0 redo size
1193 bytes sent via SQL*Net to client
277 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
7 sorts (memory)
0 sorts (disk)
13 rows processed
Query3
SELECT PR.pr_id,
sp.sp_class_destinatario,
SP.sp_sospesa,
sp.sp_id_destinatario,
IV.in_id_mittente,
IV.in_oggetto,
IV.in_data_spedizione,
PR.pr_id_soggetto,
PR.PR_NUMERO_PRATICA,
PR.pr_id_utente_presentatore
FROM PF_TR_INVIO IV, PF_TR_SITUAZIONE_PRATICA SP, PF_TR_PRATICA PR
WHERE (((SP.SP_CLASS_DESTINATARIO = 10) AND (SP.SP_ID_DESTINATARIO = 1260)) OR
((SP.SP_CLASS_DESTINATARIO = 20) AND
(exists
(select 1 from a where SP.SP_ID_DESTINATARIO=a))) OR
((SP.SP_CLASS_DESTINATARIO = 30) AND (SP.SP_ID_DESTINATARIO = 420)))
AND (SP.SP_ID_ULTIMO_INVIO = IV.IN_ID)
AND (SP.SP_ID_PRATICA = PR.PR_ID)
ORDER BY IV.IN_ID,
PR.PR_NUMERO_PRATICA
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=80 Card=11 Bytes=759
1 0 SORT (ORDER BY) (Cost=80 Card=11 Bytes=759)
2 1 FILTER
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_INVIO' (Cost=1
Card=1 Bytes=22)
4 3 NESTED LOOPS (Cost=33 Card=11 Bytes=759)
5 4 NESTED LOOPS (Cost=22 Card=11 Bytes=517)
6 5 TABLE ACCESS (FULL) OF 'PF_TR_SITUAZIONE_PRATICA
' (Cost=11 Card=11 Bytes=165)
7 5 TABLE ACCESS (BY INDEX ROWID) OF 'PF_TR_PRATICA'
(Cost=1 Card=1 Bytes=32)
8 7 INDEX (RANGE SCAN) OF 'PF_PR_IN_ID' (NON-UNIQU
E)
9 4 INDEX (RANGE SCAN) OF 'PF_IN_IN_ID' (NON-UNIQUE)
10 2 TABLE ACCESS (FULL) OF 'A' (Cost=2 Card=1 Bytes=3)
Statistics
0 recursive calls
0 db block gets
7179 consistent gets
0 physical reads
0 redo size
1193 bytes sent via SQL*Net to client
277 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
13 rows processed
Thank You in Advance,
Jaggy.Hey,
Although it is not seen in Query 2 execution plan maybe the root of the problem
(And I saw it in other selects from a collection) is that the default cardinality for a
The "COLLECTION ITERATOR PICKLER FETCH" operation is the block size of your database.
The workaround is:
1. a. give an alias for the Table(yada, yada, yada) clause.
1. b. inform the oracle on the assumed count of rows that this Table() has
Via a hint, e.g.
Select +cardinality(table_alias 20) --20 means that 20 rows will be returned
column_1, column_2
from table(yada, yada, yada) table_alias, real_table
where table_alias.id = real_table.id
Anyway, try it.
Amiel. -
11.1.0.7 SPM is not functioning
Hi all,
I'm relying on SPM to control plan change. But it's found that the SPM cannot deliver what it promises to achieve, resulting in performance regression.
The SQL Txt driven from application cannot be amended.
The explain plan complains about the plan table version is old !!Here's my SQL Statement :-
SELECT /*+ INDEX_ASC */
progress_recid unique_id_0 FROM OCMMSGSK tx WHERE (UPPER (direction) = UPPER('A') AND processed = 1 AND new_msg = 0);
SQL> show parameter baselines
NAME TYPE
VALUE
optimizer_capture_sql_plan_baselines boolean
FALSE
optimizer_use_sql_plan_baselines boolean
TRUE
SQL> show parameter baselines
NAME TYPE
VALUE
optimizer_capture_sql_plan_baselines boolean
FALSE
optimizer_use_sql_plan_baselines boolean
FALSE
SQL> set autotrace on explain
SQL> SELECT /*+ INDEX_ASC */ progress_recid unique_id_0 FROM ssu.com_msg t0 WHERE (UPPER (direction) = UPPER('A') AND processed = 1 AND new_msg = 0);
no rows selected
Execution Plan
Plan hash value: 2991302478
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2085 | 27105 | 41585(1)| 00:08:20 |
|* 1 | TABLE ACCESS BY INDEX ROWID| OCM_MSG | 2085 | 27105 | 41585(1)| 00:08:20 |
| 2 | INDEX FULL SCAN | OCM_MSGOBJID | 834K| | 2301(1)| 00:00:28 |
Predicate Information (identified by operation id):
1 - filter("PROCESSED"=1 AND "NEW_MSG"=0 AND UPPER("DIRECTION")='A')
SQL> /
no rows selected
Execution Plan
Plan hash value: 2991302478
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2085 | 27105 | 41585(1)| 00:08:20 |
|* 1 | TABLE ACCESS BY INDEX ROWID| OCM_MSG | 2085 | 27105 | 41585(1)| 00:08:20 |
| 2 | INDEX FULL SCAN | OCM_MSGOBJID | 834K| | 2301(1)| 00:00:28 |
Predicate Information (identified by operation id):
1 - filter("PROCESSED"=1 AND "NEW_MSG"=0 AND UPPER("DIRECTION")='A')
SQL> /
no rows selected
Execution Plan
Plan hash value: 904046771
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2085 | 27105 | 9616 (1)| 00:01:56 |
|* 1 | TABLE ACCESS FULL| OCM_MSG | 2085 | 27105 | 9616 (1)| 00:01:56 |
Predicate Information (identified by operation id):
1 - filter("PROCESSED"=1 AND "NEW_MSG"=0 AND UPPER("DIRECTION")='A')
SQL> explain plan for
2 SELECT /*+ INDEX_ASC */ progress_recid unique_id_0 FROM ssu.com_msg t0 WHERE (UPPER (direction) = UPPER('A') AND processed = 1 AND new_msg = 0);
Explained.
SQL> @?/rdbms/admin/catplan.sql
PLAN_TABLE_OUTPUT
Plan hash value: 904046771
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2085 | 27105 | 9616 (1)| 00:01:56 |
|* 1 | TABLE ACCESS FULL| OCM_MSG | 2085 | 27105 | 9616 (1)| 00:01:56 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("PROCESSED"=1 AND "NEW_MSG"=0 AND UPPER("DIRECTION")='A')
13 rows selected.
Execution Plan
Plan hash value: 3013799171
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 8168 | 16336 | 29 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR PICKLER FETCH| DISPLAY | | | | |
SQL> explain plan for
2 SELECT /*+ INDEX_ASC */ progress_recid unique_id_0 FROM ssu.com_msg t0 WHERE (UPPER (direction) = UPPER('A') AND processed = 1 AND new_msg = 0);
Explained.
SQL> @?/rdbms/admin/catplan.sql
PLAN_TABLE_OUTPUT
Plan hash value: 2991302478
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 2085 | 27105 | 41585(1)| 00:08:20 |
|* 1 | TABLE ACCESS BY INDEX ROWID| OCM_MSG | 2085 | 27105 | 41585(1)| 00:08:20 |
| 2 | INDEX FULL SCAN | OCM_MSGOBJID | 834K| | 2301(1)| 00:00:28 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
1 - filter("PROCESSED"=1 AND "NEW_MSG"=0 AND UPPER("DIRECTION")='A')
14 rows selected.
Execution Plan
Plan hash value: 3013799171
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 8168 | 16336 | 29 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR PICKLER FETCH| DISPLAY | | | | |
---------------------------------------------------------------------------------------------
Maybe you are looking for
-
Command used to know if Oracle is 64 bit or 32 bit in Unix
What command would you use to tell if Oracle is 64 bit or 32 bit in Unix Systems.?? What command would you use to tell if Solaris running on 64 bit or 32 bit.?? Thnx Sravan
-
How to insert a button on the column header of a table in webdynpro java
Hi Can anyone tell me how to insert a button on the column header of a table in webdynpro java? regards sunit
-
I can't delete my music, help!
i am tryin g to delete music from itunes when i have my iphone plugged in. i right click on the music that is on my phone and the only options i have are.. 1.play 2.get info 3. show in itunes store this is so frustrating!
-
Query to get sql server version information?
Hi! I'm new to sql and would appreciate it if anyone could show me the query that i need to type to get the server version information - I do not have direct access to the sql database (doing some work on an old website that runs on windows box w/ co
-
Issue with facebook information being added to contacts?
Hello, On my z10 when I set it up, I set up a facebook account as well, and it added facebook account information to some of my contacts (most of which were added though gmail CardDav). I tried deleting the account and readding it to see if I could g