XPath query rewrite and insertChildXML (10g2): Help?
Hi all,
I have a registered schema for a <log> document. The schema defines an element /log/logData and under that there, /log/logData/data having maxOccurs="unbounded". So the form of documents is
<log>
<logData>
<data>a</data>
<data>b</data>
<data>c</data>
</logData>
</log>
In the schema definition I have enabled "storeArrayAsVArray='true'". The <data> elements are stored in a nested table. Every type is stored object-relationally.
To an instance documen, I add <data> elements so:
UPDATE log SET object_value = insertChildXML(object_value, 'log/logData', 'data', '<data>foo</data>') WHERE existsNode ('/log[@uid="foo"]')
The call succeeds but the problem is that I need to make this call thousands of times. Initiallly the call might take 100 ms, but after a few hundred inserts inserting a single element takes over a second, and the time keeps increasing.
I believe at least part of the problem is that XPath query rewrites are not working for this call.
Following Chapter 6 of Oracle XML DB Developer's Guide, to debug the problem I have switched on
ALTER SESSION SET EVENTS '19021 trace name context forever, level 1';
and then every invocation causes:
ORA-19022: XML XPath functions are disabled
indicating that Oracle could not rewrite the query. Then I set
ALTER SESSION SET EVENTS '19027 TRACE NAME CONTEXT FOREVER, LEVEL 8192'
to obtain a trace file. Here is a portion of that trace:
*** 2005-10-30 16:54:44.984
*** ACTION NAME:() 2005-10-30 16:54:44.968
*** MODULE NAME:(SQL*Plus) 2005-10-30 16:54:44.968
*** SERVICE NAME:(SYS$USERS) 2005-10-30 16:54:44.968
*** SESSION ID:(137.38364) 2005-10-30 16:54:44.968
NO REWRITE
Reason ==> xseq:not optuop
NO REWRITE
Reason ==> xseq:not optuop
NO REWRITE
Reason ==> not SQLX operand
NO REWRITE
Reason ==> non sqlx expression input
NO REWRITE
Reason ==> non rewritable sqlx input
NO REWRITE
(the rest of the file repeats these lines)
I have no idea how to interpet that! Can anyone out there offer some insight/assistance?
Thanks if you can,
Hugh
Below is a complete example script. Cannot seem to get rewrite for even this simple case. By that I mean, executing both of the SELECT statements near the end yield the ORA-19022, and that executing the insertChildXML takes progressively longer to execute the more child elements there are.
Any pointers appreciated!
Hugh
set echo on
ALTER SESSION SET EVENTS '19021 trace name context forever, level 1';
ALTER SESSION SET EVENTS '19027 TRACE NAME CONTEXT FOREVER, LEVEL 8192';
exec dbms_xmlschema.deleteSchema('http://hughw.net/foo', dbms_xmlschema.DELETE_CASCADE_FORCE);
begin
dbms_xmlschema.registerSchema('http://hughw.net/foo', XMLType('<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://hughw.net/foo" xmlns="http://hughw.net/foo" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="root" xdb:defaultTable="ROOT" >
<xs:complexType xdb:SQLType="ROOT_T">
<xs:sequence>
<!-- could use out of line storage -->
<!-- commented out
<xs:element name="child" type="childType" minOccurs="0" maxOccurs="unbounded"
xdb:SQLName="CHILDREN"
xdb:SQLInline="false" xdb:defaultTable="CHILD"
/>
-->
<!-- use nested table -->
<xs:element name="child" type="childType" minOccurs="0" maxOccurs="unbounded"
xdb:SQLName="CHILDREN"
xdb:SQLCollType="CHILD_V"
/>
</xs:sequence>
<xs:attribute name="uid" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:complexType name="childType" xdb:SQLType="CHILD_T">
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:schema>'));
end;
insert into root values( XMLType('<?xml version="1.0" encoding="UTF-8"?>
<root uid="1" xmlns="http://hughw.net/foo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://hughw.net/foo http://hughw.net/foo">
<child>a</child>
<child>b</child>
<child>c</child>
</root>'));
CREATE INDEX ROOT_INDEX ON ROOT (extractValue(object_value,'/root/@uid'));
select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root;
explain plan for select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root;
SELECT PLAN_TABLE_OUTPUT FROM table(DBMS_XPLAN.display('plan_table', NULL, 'serial'));
select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root
WHERE existsNode(object_value, '/root[@uid="1"]') = 1;
explain plan for select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root
WHERE existsNode(object_value, '/root[@uid="1"]') = 1;
SELECT PLAN_TABLE_OUTPUT FROM table(DBMS_XPLAN.display('plan_table', NULL, 'serial'));
Similar Messages
-
Help with query rewrite and materialized views
Hello everybody,
I'm currently learning how to use Oracle (10G Enterprise) and in particular, Materialized Views.
I seem to have a problem making the optimizer use a materialized view. I have already set the OPTIMIZER_MODE, QUERY_REWRITE_ENABLED and QUERY_REWRITE_INTEGRITY as needed.
I need to create a materialized view for the following query:
Q1:
SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
FROM PARTSUPPLIER E, PART WHERE PS_PARTKEY=P_PARTKEY and (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'')
and PS_SUPPCOST =
(SELECT min( PS_SUPPCOST)
FROM PARTSUPPLIER I
WHERE E.PS_PARTKEY=I.PS_PARTKEY)'
I created it using the following code:
CREATE MATERIALIZED VIEW mv_q1
ENABLE QUERY REWRITE
AS SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
FROM PARTSUPPLIER E JOIN PART ON (PS_PARTKEY=P_PARTKEY)
WHERE lower(P_COMMENT) LIKE '_o_a%' or lower(P_COMMENT) LIKE '_o_u%'
and PS_SUPPCOST=
(SELECT min( PS_SUPPCOST)
FROM PARTSUPPLIER I
WHERE E.PS_PARTKEY=I.PS_PARTKEY);
I have created the statistics using:
execute dbms_stats.gather_table_stats('frandres',' mv_q1');
execute dbms_stats.gather_table_stats('frandres','PARTSUPPLIER');
execute dbms_stats.gather_table_stats('frandres','PART');
Both partsupplier and part are tables and not views.
When executing Q1, the plan does not use the materialized view. Furthermore, when using explain rewrite:
DECLARE
qrytxt VARCHAR2(3000) := 'SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
FROM PARTSUPPLIER E, PART WHERE PS_PARTKEY=P_PARTKEY and (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'')
and PS_SUPPCOST =
(SELECT min( PS_SUPPCOST)
FROM PARTSUPPLIER I
WHERE E.PS_PARTKEY=I.PS_PARTKEY)';
BEGIN
dbms_mview.EXPLAIN_REWRITE
(qrytxt,'MV_Q1','MV_Q1');
END;
I get the following message:
MESSAGE
QSM-01150: query did not rewrite
QSM-01263: query rewrite not possible when query references a dictionary table o
r view
QSM-01219: no suitable materialized view found to rewrite this query
What I can't understand is why it says I am referencing the dictionary or a view?
If I remove the (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'') condition to the query (using the same materialized view), I get the following message from EXPLAIN_REWRITE:
MESSAGE
QSM-01150: query did not rewrite
QSM-01219: no suitable materialized view found to rewrite this query
Which is reasonable.
I don't know if the like condition is messing up my materialized view. Can anyone please help?
Thanks a lot in advance.
Edited by: user12072111 on Oct 29, 2009 9:43 PMBingo!
The 10.2.0.3 patch set is supposed to fix this ( [List of bugs fixed (MVs)|http://www.dbatools.net/doc/bug10203.html#MVIEW] )
In particular:
5052568 Query rewrite does not work for SQL with LIKE clause.
Thank you very much for your message!
The downside is that I'm only using Oracle for educational purposes and consequently have no Metalink id, so I can't install the patch. Thanks a lot though! -
hi,
I am not familiar with sql query tuning know only i started learning basics so please any body can help regaring below mentioned query how to tune it.
SELECT T.TERMINALID, DECODE(A.AGENT_STATUS, 1,T.TERMINAL_STATUS,0) AS STATUS, T.SHIPMENTTYPE
FROM (SELECT TM1.TERMINALID, TM1.SHIPMENTTYPE, DECODE(TERMINALSTATUS ,'N',0,1) AS TERMINAL_STATUS
FROM (SELECT TERMINALID, SHIPMENTTYPE
FROM FS_FR_TERMINALMASTER )TM1,
(SELECT AGENTID, PROPERTY_VALUE AS TERMINALSTATUS
FROM FS_FR_AGENTHISTORY
WHERE PROPERTY_NAME ='TERMINAL_STATUS'
AND PROPERTY_DATE IN(SELECT MAX(PROPERTY_DATE)
FROM FS_FR_AGENTHISTORY
WHERE PROPERTY_NAME ='TERMINAL_STATUS'
GROUP BY AGENTID)) D
WHERE TM1.TERMINALID =D.AGENTID(+)) T,
(SELECT TM.TERMINALID, DECODE(AGENTSTATUS,'N',0,1) AS AGENT_STATUS
FROM (SELECT TERMINALID
FROM FS_FR_TERMINALMASTER )TM,
(SELECT AGENTID, PROPERTY_VALUE AS AGENTSTATUS
FROM FS_FR_AGENTHISTORY
WHERE PROPERTY_NAME ='AGENT_STATUS'
AND PROPERTY_DATE IN(SELECT MAX(PROPERTY_DATE) FROM FS_FR_AGENTHISTORY
WHERE PROPERTY_NAME ='AGENT_STATUS' GROUP BY AGENTID))B
WHERE SUBSTR(tm.TERMINALID,0,3)=AGENTID(+)) A
WHERE T.TERMINALID= A.TERMINALID
UNION
(SELECT GATEWAYID TERMIANLID, 1 STATUS, '111111' SHIPMENTTYPE
FROM FS_FR_GATEWAYMASTER
WHERE GATEWAYID NOT IN (SELECT TERMINALID FROM FS_FR_TERMINALMASTER ));
Explain Plan :-
SELECT STATEMENT, GOAL = ALL_ROWS Cost=38 Cardinality=927
SORT UNIQUE Cost=38 Cardinality=927
UNION-ALL
HASH JOIN RIGHT OUTER Cost=32 Cardinality=925
VIEW Object owner=EXPO0626 Cost=12 Cardinality=210
HASH JOIN Cost=12 Cardinality=210
VIEW Object owner=SYS Object name=VW_NSO_1 Cost=6 Cardinality=413
SORT GROUP BY Cost=6 Cardinality=413
TABLE ACCESS FULL Object owner=EXPO0626 Object name=FS_FR_AGENTHISTORY Cost=5 Cardinality=466
TABLE ACCESS FULL Object owner=EXPO0626 Object name=FS_FR_AGENTHISTORY Cost=5 Cardinality=466
NESTED LOOPS Cost=20 Cardinality=925
HASH JOIN RIGHT OUTER Cost=18 Cardinality=925
VIEW Object owner=EXPO0626 Cost=12 Cardinality=210
HASH JOIN Cost=12 Cardinality=210
VIEW Object owner=SYS Object name=VW_NSO_2 Cost=6 Cardinality=413
SORT GROUP BY Cost=6 Cardinality=413
TABLE ACCESS FULL Object owner=EXPO0626 Object name=FS_FR_AGENTHISTORY Cost=5 Cardinality=466
TABLE ACCESS FULL Object owner=EXPO0626 Object name=FS_FR_AGENTHISTORY Cost=5 Cardinality=466
TABLE ACCESS FULL Object owner=EXPO0626 Object name=FS_FR_TERMINALMASTER Cost=6 Cardinality=925
INDEX UNIQUE SCAN Object owner=EXPO0626 Object name=PK_TERM Cost=0 Cardinality=1
NESTED LOOPS ANTI Cost=4 Cardinality=2
INDEX FAST FULL SCAN Object owner=EXPO0626 Object name=SYS_C0054927 Cost=2 Cardinality=927
INDEX UNIQUE SCAN Object owner=EXPO0626 Object name=PK_TERM Cost=0 Cardinality=923
Regards,
Srinivas.Hi
explain plan SET STATEMENT_ID = 'VD20001' for < your query>
and then
SELECT * FROM TABLE(dbms_xplan.display('plan_table','VD20001','TYPICAL'));
why we need to set above statment and what do you mean by 'VD20001' and
how to read this plan generated by this statment "SELECT * FROM TABLE(dbms_xplan.display('plan_table','VD20001','TYPICAL'));" .
Below mentioned is the plan generated according to your commands.
SQL> select * from table(dbms_xplan.display('plan_table','VD20001','TYPICAL'));
| Id | Operation | Name | Rows |
Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 6 |
1068 | 76 (12)|
| 1 | SORT AGGREGATE | | 1 |
45 | |
|* 2 | TABLE ACCESS BY INDEX ROWID | FS_AC_INVOICEALLOCATION | 1 |
45 | 3 (0)|
|* 3 | INDEX RANGE SCAN | PK_INV_VOU_REF | 1 |
| 2 (0)|
| 4 | SORT AGGREGATE | | 1 |
45 | |
|* 5 | TABLE ACCESS BY INDEX ROWID | FS_AC_INVOICEALLOCATION | 1 |
45 | 3 (0)|
|* 6 | INDEX RANGE SCAN | PK_INV_VOU_REF | 1 |
| 2 (0)|
| 7 | SORT GROUP BY | | 6 |
1068 | 76 (12)|
| 8 | MERGE JOIN CARTESIAN | | 6 |
1068 | 74 (11)|
|* 9 | VIEW | FS_AC_AGEING_VIEW | 2 |
318 | 56 (4)|
| 10 | SORT UNIQUE | | 2 |
307 | 56 (43)|
| 11 | UNION-ALL | | |
| |
| 12 | NESTED LOOPS | | 1 |
178 | 32 (0)|
| 13 | NESTED LOOPS | | 4 |
536 | 27 (0)|
| 14 | MERGE JOIN CARTESIAN | | 3 |
219 | 18 (0)|
|* 15 | INDEX RANGE SCAN | FS_AC_COMPANYINFO_IDX_015 | 1 |
9 | 2 (0)|
| 16 | BUFFER SORT | | 1214 |
77696 | 16 (0)|
|* 17 | INDEX RANGE SCAN | FS_AC_ACCTMASTER_IDX_013 | 1214 |
77696 | 16 (0)|
| 18 | TABLE ACCESS BY INDEX ROWID| FS_AC_VOUCHERDTL | 1 |
61 | 3 (0)|
|* 19 | INDEX RANGE SCAN | FS_AC_VOUCHERDTL_IDX_016 | 1 |
| 2 (0)|
|* 20 | TABLE ACCESS BY INDEX ROWID | FS_AC_VOUCHERMASTER | 1 |
44 | 2 (0)|
|* 21 | INDEX UNIQUE SCAN | PK_VT_VN_BK | 1 |
| 1 (0)|
|* 22 | TABLE ACCESS BY INDEX ROWID | FS_AC_OPGBALDTL | 1 |
56 | 2 (0)|
| 23 | NESTED LOOPS | | 1 |
129 | 22 (0)|
| 24 | MERGE JOIN CARTESIAN | | 3 |
219 | 18 (0)|
|* 25 | INDEX RANGE SCAN | FS_AC_COMPANYINFO_IDX_015 | 1 |
9 | 2 (0)|
| 26 | BUFFER SORT | | 1214 |
77696 | 16 (0)|
|* 27 | INDEX RANGE SCAN | FS_AC_ACCTMASTER_IDX_013 | 1214 |
77696 | 16 (0)|
|* 28 | INDEX RANGE SCAN | PK_OPGBALDTL | 1 |
| 1 (0)|
|* 29 | INDEX RANGE SCAN | FS_AC_ACCTSUBGRP_IDX1 | 1 |
27 | 1 (0)|
| 30 | BUFFER SORT | | 3 |
57 | 75 (12)|
| 31 | VIEW | | 3 |
57 | 9 (34)|
| 32 | SORT UNIQUE | | 3 |
18 | 9 (78)|
| 33 | UNION-ALL | | |
| |
|* 34 | INDEX FAST FULL SCAN | SYS_C0054818 | 8 |
24 | 2 (0)|
|* 35 | INDEX FAST FULL SCAN | SYS_C0054818 | 7 |
21 | 2 (0)|
| 36 | TABLE ACCESS BY INDEX ROWID | FS_FR_CURRENCYMASTER | 1 |
12 | 2 (0)|
|* 37 | INDEX UNIQUE SCAN | SYS_C0054818 | 1 |
| 1 (0)|
Predicate Information (identified by operation id):
2 - filter(TRUNC("VOUCHERDATE")<SYSDATE@!)
3 - access("VOUCHERTYPE"=:B1 AND "VOUCHERNUMBER"=:B2 AND "ACCTCODE"=:B3 AND "
BOOKID"=:B4)
filter("ACCTCODE"=:B1 AND "BOOKID"=:B2)
5 - filter(TRUNC("VOUCHERDATE")<=SYSDATE@!)
6 - access("VOUCHERTYPE"=:B1 AND "VOUCHERNUMBER"=:B2 AND "ACCTCODE"=:B3 AND "
BOOKID"=:B4)
filter("ACCTCODE"=:B1 AND "BOOKID"=:B2)
9 - filter("A"."ACCTCODE" LIKE (SELECT "SUBGRPCODE" FROM "FS_AC_ACCTSUBGRPMA
STER"
"FS_AC_ACCTSUBGRPMASTER" WHERE "SUBGRPNAME"='LOCAL DEBTORS')||'AR%
15 - access("CI"."COMPANYID"='EXPMAA' AND "CI"."BOOKID"<=2)
filter("CI"."COMPANYID"='EXPMAA' AND "CI"."BOOKID"<=2)
17 - access("AM"."TERMINALID"='EXPMAA')
19 - access("AM"."ACCTCODE"="VD"."ACCTCODE" AND "VD"."BOOKID"<=2)
filter("VD"."BOOKID"<=2 AND ("VD"."ACCTCODE" LIKE '%AR_____' OR "VD"."ACC
TCODE" LIKE
'%AP_____') AND "BANKCASHPARTYCODEIND" NOT LIKE 'F%')
20 - filter("VM"."APPROVALSTATUS"='Y' AND TRUNC("VOUCHERDATE")<=SYSDATE@!)
21 - access("VM"."VOUCHERTYPE"="VD"."VOUCHERTYPE" AND
"VM"."VOUCHERNUMBER"="VD"."VOUCHERNUMBER" AND "VD"."BOOKID"="VM"."
BOOKID")
filter("VM"."BOOKID"<=2 AND "CI"."BOOKID"="VM"."BOOKID")
22 - filter("STATUS" NOT LIKE 'F%' AND TRUNC("DOCDATE")<=SYSDATE@!)
25 - access("CI"."COMPANYID"='EXPMAA' AND "CI"."BOOKID"<=2)
filter("CI"."COMPANYID"='EXPMAA' AND "CI"."BOOKID"<=2)
27 - access("AM"."TERMINALID"='EXPMAA')
28 - access("AM"."ACCTCODE"="OP"."ACCTCODE" AND "CI"."BOOKID"="OP"."BOOKID")
filter("OP"."BOOKID"<=2 AND ("OP"."ACCTCODE" LIKE '%AR_____' OR "OP"."ACC
TCODE" LIKE
'%AP_____'))
29 - access("SUBGRPNAME"='LOCAL DEBTORS')
34 - filter("CURRENCY1"='INR')
35 - filter("CURRENCY2"='INR')
37 - access("CURRENCY1"='INR' AND "CURRENCY2"='INR')
Note
- 'PLAN_TABLE' is old version
80 rows selected.
Regards,
Srinivas. -
Materialized views - schedule, indexes, query rewrite, etc.
I'm trying to get the hang of materialized views and need some help . . .
running Oracle 10gR2
I created a materialized view as follows:
CREATE MATERIALIZED VIEW "MY_SCHEMA"."USERS"
AS
SELECT * FROM "USERS"@PRODUCTION -- to copy the USERS table from my production database to this database
Worked fine. So far so good. Then, I altered it to schedule the refresh:
ALTER MATERIALIZED VIEW "MY_SCHEMA"."USERS" REFRESH FORCE START WITH SYSDATE NEXT TRUNC(SYSDATE + 1) + 4/24
-- to schedule a refresh immediately (SYSDATE) and every morning thereafter at 4:00 am (I think)
then, I wanted to enable query rewrite, so I issued the following command:
ALTER MATERIALIZED VIEW "MY_SCHEMA"."USERS" ENABLE QUERY REWRITE;
and I got the
ALTER MATERIALIZED VIEW succeeded.
message for both of those commands (I'm doing this in SQL Developer).
Then, I edit the materialized view in SQL Developer, click on the 'SQL' tab, and get the following:
CREATE MATERIALIZED VIEW "MY_SCHEMA"."USERS"
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "TBLSPC_PHIGH"
BUILD IMMEDIATE
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "TBLSPC_PHIGH"
REFRESH FORCE ON DEMAND START WITH sysdate+0 NEXT TRUNC(SYSDATE + 1) + 4/24
WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS SELECT "USERS"."User" "User","USERS"."Logon" "Logon","USERS"."Name" "Name","USERS"."Password"
"Password","USERS"."Level" "Level","USERS"."Producer" "Producer","USERS"."Deleted" "Deleted","USERS"."ClaimDoctor"
"ClaimDoctor","USERS"."UserType" "UserType","USERS"."Locked" "Locked","USERS"."Scheduler"
"Scheduler","USERS"."RestrictDays" "RestrictDays","USERS"."First" "First","USERS"."DisableAutoChart"
"DisableAutoChart","USERS"."MaxChartOut" "MaxChartOut","USERS"."MaxHoursOut" "MaxHoursOut","USERS"."EffDate"
"EffDate","USERS"."ExpDate" "ExpDate","USERS"."SwipeLogon" "SwipeLogon","USERS"."SwipePassword"
"SwipePassword","USERS"."PwdLastChanged" "PwdLastChanged","USERS"."Audit" "Audit","USERS"."IsInstructor"
"IsInstructor" FROM "USERS"@PRODUCTION.REGRESS.RDBMS.DEV.US.ORACLE.COM "USERS";
The problems I've encountered so far:
1) I created this two days ago and changed the value of one column in one row in the 'source' USERS table
(USERS@PRODUCTION) as a test case. So far, that change has not propagated over to my materialized view even though
it has had two chances to do so (yesterday morning at 4:00 am and this morning at 4:00 am).
2) I enabled QUERY REWRITE. Why does it still show DISABLE?
3) The primary key of the table came over (as far as I can tell) because it shows in SQL Developer. However, the
indexed columns are no longer indexed. Do I need to recreate those indexes manually and will they persist?
4) As you have guessed, I have just taken the plunge into materialized views, and have not been able to find
anything on the Web along the lines of 'Materialized Views for Dummies'. So, any and all advice/suggestions/help
will be welcome.
Thanks,
CarlThe Refresh would be executed by a job submitted in the background.
Query USER_JOBS (or DBA_JOBS) to see if a job has been submitted and if it has been running (you'd be able to see LAST_DATE, LAST_SEC and NEXT_DATE and NEXT_SEC). \
If the Refresh job has been failing the FAILURES count would be incremented. If there are 16 consecutive failures, the job is marked BROKEN. (if a job fails, Oracle retries it automatically and keeps retrying till it is BROKEN). If the job has been failing you would get messages in the database instance alert log file and trace files.
If the Refresh job has not been running check the parameter value for JOB_QUEUE_PROCESSES -- a value of 0 would not run in jobs in the USER_JOBS/DBA_JOBS view. Ask the DBA to increase set this parameter to at least 1.
Hemant K Chitale
http://hemantoracledba.blogspot.com -
No query rewriting in a star schema
Gentlemen,
I am facing a problem with query rewriting in a simple data warehouse star schema. I want to take advantage of the built-in roll up along dimensions of a star schema. Therefore, I created several DIMENSIONs and made sure that all foreign key/primary key relationships between fact and dimension tables are set up correctly. In addition, as many table attributes as possible are assigned the NOT NULL constraint, especially the ones that are used by the CHILD Of and ATTRIBUTE relationships.
I defined materialized views on the fact table and a couple of dimension tables to report on aggregated data. All the MVIEWs are enabled for query rewriting and I have the initialization parameter set correctly (QUERY_REWRITE_INTEGRITY is set to TRUSTED).
From my tests I learned that a query is rewritten correctly only of the corresponding MVIEW contains the fact table and one dimension table. This is true for every dimension I created. However, as soon as the MVIEW joins more than one dimension table to the fact table the rewriting mechanism fails. It appears that the roll-up (aggregation along the hierarchy) is only possible for one of the dimensions. If the original query suggests rolling-up more than one dimension (e.g., "summarize the key figures by year and product category" but the underlying dimension is based on month and product), the MVIEW is no longer rewritten at all.
Do you know this effect from your work experience? Is this a bug or have I made a mistake or forgotten to switch on a special feature?
Here are some technical data of our data warehouse: we are running an Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 on a Windows Server 2003, the size of the database is about 10 GB (excluding indexes), the star schema contains ten dimension tables each one with a simple or parallel hierarchies (e.g. a product dimension). The fact table and the MVIEWS are partitioned by month.
Any help is very welcome.
Regards,
JohnHi,
you may ask with DBMS_MVIEW why your query does not get rewritten:
Maybe you have to create a util table first with
SQL> @?/rdbms/admin/utlxrw.sql
Then you ask:
SQL> begin
DBMS_MVIEW.EXPLAIN_REWRITE('<your query without ; at the end>');
end;
The reason why it is not rewritten:
SQL> select message from rewrite_table order by sequence;
Kind regards
Uwe -
Query rewrite does not always work?
Hi -
I created several cubes at this point.
Cube #1: simple time and volume. Query re-write works great.
Cube #2: simple customer (geography) hierarchy and volume. Query re-write works great.
Cube #3: Added product dimension along with time and customer. I also added ytd volume and same period prior period volume calculations.
The Cube#3 is not peforming a query re-write.
All cubes have MV and Query rewrite enabled.
I am using lastest verisons of 11G and AWM.
Any ideas how to debug why query rewrite is not working?
Thanks,
Frank.Hi Frank,
See the information at the following link:- https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=577293.1
This is titled 'Oracle OLAP 11g: How to ensure use of Cube Materialized Views/Query Rewrite'
I hope it helps
Thanks,
Stuart Bunby
OLAP Blog: http://oracleOLAP.blogspot.com
OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
OLAP on OTN: http://www.oracle.com/technology/products/bi/olap/index.html
DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html -
Spatial vs. materialized views/query rewrite
Dear all,
we are trying to use Spatial (Locator) functionality together with performance optimization using materialized views and query rewrite, and it does not seem to work. Does anybody has experience with this?
The problem in more detail:
* There is a spatial attribut (vom Typ GEOMETRY) in our table;
* we define a materialized view on that table;
* we run a query that could be better answered using the materialized view with query rewrite;
*the optimizer does not choose the plan using the materialized view, query rewrite does not take place;
This happenes, even if neither the materialized view, nor the query contains the spatial attribut.
The explanation given by the procedure DBMS_MVIEW.Explain_Rewrite is:
"QSM-01064 query has a fixed table or view Cause: Query
rewrite is not allowed if query references any fixed tables or views"
We are using Oracle 9R2, Enterprise Edition, with locator. Nevertheless, it would also be interesting, if there is any improvement in 10g?
A more complicated task, using materialized views to optimize spatial operations (e.g., sdo_relate) would also be very interesting, as spatial joins are very expensive operations.
Thanks in advance for any comments, ideas!
Cheers,
Gergely LukacsHi Dan,
thanks for your rapid response!
A simple example is:
alter session set query_rewrite_integrity=trusted;
alter session set query_rewrite_enabled=true;
set serveroutput on;
/* Creating testtable */
CREATE TABLE TESTTABLE (
KEY1 NUMBER (4) NOT NULL,
KEY2 NUMBER (8) NOT NULL,
KEY3 NUMBER (14) NOT NULL,
NAME VARCHAR2 (255),
X NUMBER (9,2),
Y NUMBER (9,2),
ATTR1 VARCHAR2 (2),
ATTR2 VARCHAR2 (30),
ATTR3 VARCHAR2 (80),
ATTR4 NUMBER (7),
ATTR5 NUMBER (4),
ATTR6 NUMBER (5),
ATTR7 VARCHAR2 (40),
ATTR8 VARCHAR2 (40),
CONSTRAINT TESTTABLE_PK
PRIMARY KEY ( KEY1, KEY2, KEY3 ));
/* Creating materialized view */
CREATE MATERIALIZED VIEW TESTTABLE_MV
REFRESH COMPLETE
ENABLE QUERY REWRITE
AS SELECT DISTINCT ATTR7, ATTR8
FROM TESTTABLE;
/* Creating statistics, just to make sure */
execute dbms_stats.gather_table_stats(ownname=> 'TESTSCHEMA', tabname=> 'TESTTABLE', cascade=>TRUE);
execute dbms_stats.gather_table_stats(ownname=> 'TESTSCHEMA', tabname=> 'TESTTABLE_MV', cascade=>TRUE);
/* Explain rewrite procedure */
DECLARE
Rewrite_Array SYS.RewriteArrayType := SYS.RewriteArrayType();
querytxt VARCHAR2(1500) :=
'SELECT COUNT(*) FROM (
SELECT DISTINCT
ATTR8 FROM
TESTTABLE
i NUMBER;
BEGIN
DBMS_MVIEW.Explain_Rewrite(querytxt, 'TESTTABLE_MV', Rewrite_Array);
FOR i IN 1..Rewrite_Array.count
LOOP
DBMS_OUTPUT.PUT_LINE(Rewrite_Array(i).message);
END LOOP;
END;
The message you get is:
QSM-01009 materialized view, string, matched query text
Cause: The query was rewritten using a materialized view, because query text matched the materialized view text.
Action: No action required.
i.e. query rewrite works!
/* Adding geometry column to the testtable -- not to the materialized view, and not to the query! */
ALTER TABLE TESTTABLE
ADD GEOMETRYATTR mdsys.sdo_geometry;
/* Explain rewrite procedure */
DECLARE
Rewrite_Array SYS.RewriteArrayType := SYS.RewriteArrayType();
querytxt VARCHAR2(1500) :=
'SELECT COUNT(*) FROM (
SELECT DISTINCT
ATTR8 FROM
TESTTABLE
i NUMBER;
BEGIN
DBMS_MVIEW.Explain_Rewrite(querytxt, 'TESTTABLE_MV', Rewrite_Array);
FOR i IN 1..Rewrite_Array.count
LOOP
DBMS_OUTPUT.PUT_LINE(Rewrite_Array(i).message);
END LOOP;
END;
The messages you get are:
QSM-01064 query has a fixed table or view
Cause: Query rewrite is not allowed if query references any fixed tables or views.
Action: No action required.
QSM-01019 no suitable materialized view found to rewrite this query
Cause: There doesn't exist any materialized view that can be used to rewrite this query.
Action: Consider creating a new materialized view.
i.e. query rewrite does not work!
If this works, the next issue is to use materialized views for optimizing spatial operations, e.g., a spatial join. I can supply you with an example, if necessary (only makes sense, I think, after the first problem is solved).
Thanks in advance for any ideas, comments!
Cheers,
Gergely -
Risky enable star transformations and trusted Query Rewrites?
Hi,
I need some advice/opinions from someone experienced with large scale
data warehousing.
I'm working on a fairly large data warehouse (around 3 TB), and we're
using Oracle 10.1.0.2.0.
So, I found out about MV's and Star Transformations, and that we're not
using them.
Naturally I decided to try them out in our test environment and I was
more than pleased (actually, I nearly wet my pants) with the potential
performance boost we could get for some of our more critical solutions.
However, I also noticed that the production environment has the
following settings:
star_transformation_enabled = false
query_rewrite_integrity = enforced
...which basically disables all the cool stuff. In the testing
environment I used the following:
star_transformation_enabled = true
query_rewrite_integrity = trusted (to make use of func. dep in
dimensions)
I would like to stand on somewhat solid grounds and increase my
understanding before aproaching our DBA's with the suggestion to change
system global settings :)
Basically, my question(s) are:
1. What are the impact of enabling Star Transformations on a system?
Is there any at all, if no previous solution has been built in a way
to
make use of star transformations?
Or could this change result in fine-tuned queries performing badly
since they
suddenly make use of star transformations?
2. Is "query_rewrite_integrity" used by Oracle for other things besides
Materialized Views?
I'm thinking, if the only thing it's used for is to resolve query
rewrites for MV's, then it's safe to change it, because there are no
such MV's.
Note that I'd like to set it to TRUSTED, in order to make real use
of the dependencies declared with CREATE DIMENSION...
I would be happy to know what you think about this.
Any thoughts, opinions are welcome since this is new grounds for me.
Best Regards
R.Following parameters are deprecated in release 10.2.
LOGMNR_MAX_PERSISTENT_SESSIONS
MAX_COMMIT_PROPAGATION_DELAY
REMOTE_ARCHIVE_ENABLE
SERIAL_REUSE
SQL_TRACE
Check this in your parameter file.
As per Oracle Errors Documents.
Error : ORA-32004
Cause: One or more obsolete and/or parameters were specified in the
SPFILE or the PFILE on the server side.
Action: See alert log for a list of parameters that are obsolete. or
deprecated. Remove them from the SPFILE or the server side PFILE
Regards,
Sabdar Syed. -
Map Viewer Query Rewriting for Dynamic themes and Materialized Views.
Hi,
I am usng a WMS request to render FOI points in my map.
Internally query rewrite is happening in Mapviewer for this dynamic theme and my data points query is getting converted as
select FROM
( select status, shape from MatView.MyTab where id = '3' )
WHERE MDSYS.SDO_FILTER(shape, MDSYS.SDO_GEOMETRY(2003, 4283, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(144.948120117188,-37.8162934802451,144.950866699219,-37.8141237016045)), 'querytype=WINDOW') = 'TRUE'
here the rewritten query is not correct and is throwing exceptions in mapviewer log
How can I make this query to be written correctly.
(My orginal query before rewrite is: select status,shape from MatView.MyTab where id='3' )
I am using a materialised view : MatView is a materialized view.
When I used normal tables, the query is re written correctly.But for this materialized view this is happening.
How can I correct the error?
Is this has something to do with some Spatial Indexing in Materialised view or Query Rewriting for materialized view?
Edited by: 841309 on Mar 10, 2011 11:04 PMOops!
The Materialized view was not accessible from the schema I tried :)
And so when I gave permissions,it formed the correct query.
So if permission is not there,map viewer will rewrite the query in a wrong way! New information. -
Query Rewrite (QSM-01263) and Views in Execution Plan
Hello!
I created a query rewrite enabled materialized view from a query, which contains only tables (no views). Query rewrite didn't work, so i checked the query with dbms_mview.explan_rewrite, which told my that my query contains references to views or dictionary tables. I checked my query again, but there are only tables, no views, no dictionary tables.
When I look in the execution plan of my query I see that the query optimizer generates views, I guess from my subquery (?). "A view definition was processed, either from a stored view...or as defined by steps...".
I suppose that's the reason why my query rewrite doesn't work. All my other mat views are working fine, so the usual parameters (query_rewrite_enabled, integrity, etc.) are set correctly.
Do you have any ideas how to get my query rewrite enabled work?
Thanks!Modifying the query (potentially with hints) so that Oracle doesn't do the view transformation would be one option.
-
Are Cube organized materialized view with Year to Date calculated measure eligible for Query Rewrite
Hi,
Will appreciate if someone can help me with a question regarding Cube organized MV (OLAP).
Does cube organized materialized view with calculated measures based on time series Year to date, inception to date eg.
SUM(FCT_POSITION.BASE_REALIZED_PNL) OVER (HIERARCHY DIM_CALENDAR.CALENDAR BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT DIMENSION LEVEL DIM_CALENDAR."YEAR")
are eligible for query rewrites or these are considered advanced for query rewrite purposes.
I was hoping to find an example with YTD window function on physical fact dim tables with optimizer rewriting it to Cube Org. MV but not much success.
Thanks in advanceI dont think this is possible.
(My own reasoning)
Part of the reason query rewrite works for base measures only (not calc measures in olap like ytd would be) is due to the fact that the data is staged in olap but its lineage is understandable via the olap cube mappings. That dependency/source identification is lost when we build calculated measures in olap and i think its almost impossible for optimizer to understand the finer points relating to an olap calculation defined via olap calculation (olap dml or olap expression) and also match it with the equivalent calculation using relational sql expression. The difficulty may be because both the olap ytd as well as relational ytd defined via sum() over (partition by ... order by ...) have many non-standard variations of the same calculation/definition. E.g: You can choose to use or choose not to use the option relating to IGNORE NULLs within the sql analytic function. OLAP defn may use NASKIP or NASKIP2.
I tried to search for query rewrite solutions for Inventory stock based calculations (aggregation along time=last value along time) and see if olap cube with cube aggregation option set to "Last non-na hierarchical value" works as an alternative to relational calculation. My experience has been that its not possible. You can do it relationally or you can do it via olap but your application needs to be aware of each and make the appropriate backend sql/call. In such cases, you cannot make olap (aw/cubes/dimensions) appear magically behind the scenes to fulfill the query execution while appearing to work relationally.
HTH
Shankar -
Copying Variables in BPEL using XPath Query
Hi,
I am new to BPEL and i want to know if it is possible to copy data from one variable to another using XPath Query in the <from> <to> tags, when the two variables are of different message types.
I am trying to create a sample BPEL that would receive a String through the receive tag tied to one partner link (WSDl) and then invoke a different webservice using the <invoke> tag tied to another partner link (WSDL) by passing the received variable.
I have pasted the BPEL File and the two WSDl files involved.
My Issue is that when I send a soap request to the BPEL, it is passed as null to the webservice invoked.
Probably because the copy tags don't work.
Please help.
BPEL File
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<process name="HelloWorld2"
targetNamespace="http://ode/bpel/unit-test"
xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:tns="http://ode/bpel/unit-test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://ode/bpel/unit-test.wsdl"
xmlns:ns0="http://poc.com"
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
<import location="HelloWorld2.wsdl"
namespace="http://ode/bpel/unit-test.wsdl"
importType="http://schemas.xmlsoap.org/wsdl/" />
<import location="sayHello.wsdl"
namespace="http://poc.com"
importType="http://schemas.xmlsoap.org/wsdl/" />
<partnerLinks>
<partnerLink name="helloPartnerLink"
partnerLinkType="test:HelloPartnerLinkType"
myRole="me" />
<partnerLink name="sayHelloBPELPL"
partnerLinkType="ns0:sayHelloPLT"
partnerRole="you" initializePartnerRole="yes" />
</partnerLinks>
<variables>
<variable name="myVar" messageType="test:HelloMessage"/>
<variable name="tmpVar" messageType="test:HelloMessage"/>
<variable name="inVar" messageType="ns0:sayHelloRequest"/>
<variable name="outVar" messageType="ns0:sayHelloResponse"/>
</variables>
<sequence>
<receive
name="start"
partnerLink="helloPartnerLink"
portType="test:HelloPortType"
operation="hello"
variable="myVar"
createInstance="yes"/>
<assign name="ass1">
<copy>
<from variable = "myVar" part = "TestPart"/>
<to variable = "inVar"
part = "parameters"
query= "/sayHello/ns0:param0" />
</copy>
</assign>
<invoke partnerLink = "sayHelloBPELPL"
portType = "ns0:sayHelloPortType"
inputVariable = "inVar"
operation = "sayHello"
outputVariable = "outVar">
</invoke>
<assign name="ass2">
<copy>
<from variable = "outVar"
part = "parameters"
query= "/sayHelloResponse/ns0:return" />
<to variable = "tmpVar" part="TestPart"/>
</copy>
</assign>
<reply name="end"
partnerLink="helloPartnerLink"
portType="test:HelloPortType"
operation="hello"
variable="tmpVar"/>
</sequence>
</process>
WSDL File1
<?xml version="1.0" encoding="utf-8" ?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<wsdl:definitions
targetNamespace="http://ode/bpel/unit-test.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ode/bpel/unit-test.wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns:ns0="http://poc.com">
<wsdl:message name="HelloMessage">
<wsdl:part name="TestPart" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="HelloPortType">
<wsdl:operation name="hello">
<wsdl:input message="tns:HelloMessage" name="TestIn"/>
<wsdl:output message="tns:HelloMessage" name="TestOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="hello">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input>
<soap:body
namespace="http://ode/bpel/unit-test.wsdl"
use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body
namespace="http://ode/bpel/unit-test.wsdl"
use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloService">
<wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
<soap:address location="http://localhost:8082/ode/processes/helloWorld"/>
</wsdl:port>
</wsdl:service>
<plnk:partnerLinkType name="HelloPartnerLinkType">
<plnk:role name="me" portType="tns:HelloPortType"/>
<plnk:role name="you" portType="tns:HelloPortType"/>
</plnk:partnerLinkType>
</wsdl:definitions>
WSDL File 2
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns0="http://poc.com"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns1="http://org.apache.axis2/xsd"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
targetNamespace="http://poc.com">
<wsdl:types>
<xs:schema xmlns:ns="http://poc.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://poc.com">
<xs:element name="sayHello">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="param0" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns0:sayHello" />
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns0:sayHelloResponse" />
</wsdl:message>
<wsdl:portType name="sayHelloPortType">
<wsdl:operation name="sayHello">
<wsdl:input message="ns0:sayHelloRequest" wsaw:Action="urn:sayHello" />
<wsdl:output message="ns0:sayHelloResponse" wsaw:Action="urn:sayHelloResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="sayHelloSOAP11Binding" type="ns0:sayHelloPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document"/>
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="sayHello">
<wsdl:port name="sayHelloPort" binding="ns0:sayHelloSOAP11Binding">
<soap:address location="http://localhost:8082/ode/processes/sayHello" />
</wsdl:port>
</wsdl:service>
<plnk:partnerLinkType name="sayHelloPLT">
<plnk:role name="me" portType="ns0:sayHelloPortType"/>
<plnk:role name="you" portType="ns0:sayHelloPortType"/>
</plnk:partnerLinkType>
</wsdl:definitions>Hi,
Yes, it very much is possible.
Xpath query provides a lot many data type conversion functions(string to int, string to date etc), which can be used in copying variables.
thanks
Saurabh -
Retrieve xml attribute value of nth xml node using xpath query
I have an xml with following stucture...
<xml>
<header>
<DocumentReference OrderId="order001">
<DocumentReference OrderId="order002">
<DocumentReference OrderId="order003">
I have to loop through this xml and retrieve the orderId values inside Biztalk orchestration.
In the expression shape, I get the count of 'DocumentReference' nodes using an xpath query and then
Added a loopshape to make sure it loops thru all nodes
Loop condition: n<=nodeCount (where n is an integer variable, n=0 to begin with, incremented by 1 thru each loop, nodeCount is # of DocumentReference nodes)
I try retrieve to the orderId in the following expression shape using the below xpath query
xpathQuery = System.String.Format("//*[local-name()='OrderReference'][{0}]/@orderID)",n);
sOrderId = xpath(MsgSingleInvoice,xpathQuery);
And I get the following exception:
Inner exception: '//*[local-name()='OrderReference'][1]/@orderID)' has an invalid token.
Exception type: XPathException
Appreciate any help! thanks!Thanks for the quick response. I got rid of it.
And I see a different error:
Inner exception: Specified cast is not valid. Exception type: InvalidCastException
Source: Microsoft.XLANGs.Engine
Target Site: System.Object XPathLoad(Microsoft.XLANGs.Core.Part, System.String, System.Type)
Since variable 'n' is of integer type, I suspected it and changed it to n.ToString() and tested again and still see the same error. -
Materialized Views with Query Rewrite is not getting re-written
I have tried everything that has been mentioned in all the forums here and on metalink to fix this issue, has any smart APEX user found a solution?
The issue is the MV with Query rewrite capability is not being re-written.
Things I have tried
1) give all Query Rewrite privileges to all 3 APEx schemas and parsing schema;
2) check trace files with tkprof;
3) dynamically printed explain plan from v$_SQL on the page while executing the query;
4) to test in a different environment i created an another DAD using the pl/sql webtool kit and tried the same thing and rewrite works like a charm...
whats the issue here...why are apex schemas not re-writing the queries????
appreciate any help...thanksJes, per your request
--create materialized view
CREATE MATERIALIZED VIEW "RPLANSWEB"."MV_FCG_ALL_SUMMARY_TAB"
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 81920 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "RPLANSWEB"
BUILD IMMEDIATE
USING INDEX
REFRESH FORCE ON DEMAND
USING DEFAULT LOCAL ROLLBACK SEGMENT
ENABLE QUERY REWRITE
AS SELECT fcg, year, fcg_desc,
fac, efr, fac_desc, efr_desc,
ums_round, fcg_allow_drillable allow_drillable,
MAX(category_code_um1) category_code_um1,
SUM(perm_asset) perm_asset,
SUM(temp_asset) temp_asset,
SUM(semi_asset) semi_asset,
SUM(lease_asset) lease_asset,
SUM(planned_constr) planned_constr,
SUM(all_perm_asset) all_perm_asset,
SUM(total_asset) total_asset,
SUM(allow) allow, SUM(rqmt) rqmt,
SUM(perm_planned_constr) perm_planned_constr,
SUM(perm_planned_constr_rqmt_delta) perm_planned_constr_rqmt_delta,
ROUND(DECODE(SUM(rqmt), 0, 0, SUM(all_perm_asset)/SUM(rqmt)*100)) perm_rqmt_pctsat,
ROUND(DECODE(SUM(allow), 0, 0, SUM(all_perm_asset)/SUM(allow)*100)) perm_allw_pctsat,
ROUND(DECODE(SUM(rqmt), 0, 0, SUM(total_asset)/SUM(rqmt)*100)) total_rqmt_pctsat,
ROUND(DECODE(SUM(allow), 0, 0, SUM(total_asset)/SUM(allow)*100)) total_allw_pctsat,
ROUND(DECODE(SUM(all_perm_asset), 0, 0, SUM(rqmt)/SUM(all_perm_asset)*100)) perm_rqmt_pctutl,
ROUND(DECODE(SUM(all_perm_asset), 0, 0, SUM(allow)/SUM(all_perm_asset)*100)) perm_allw_pctutl,
ROUND(DECODE(SUM(total_asset), 0, 0, SUM(rqmt)/SUM(total_asset)*100)) total_rqmt_pctutl,
ROUND(DECODE(SUM(total_asset), 0, 0, SUM(allow)/SUM(total_asset)*100)) total_allw_pctutl,
SUM(coarse_screen_asset) coarse_screen_asset,
SUM(total_excess) total_excess,
SUM(total_deficit) total_deficit,
SUM(perm_excess) perm_excess,
SUM(perm_deficit) perm_deficit,
SUM(all_perm_excess) all_perm_excess,
SUM(all_perm_deficit) all_perm_deficit,
SUM(temp_excess) temp_excess,
SUM(satisfy_rqmt) satisfy_rqmt
FROM summary_tab_dd
GROUP BY fcg, year, fcg_desc,
fac, efr, fac_desc, efr_desc,
ums_round, fcg_allow_drillable;
sql plus> log in as parsing schema user (not APEX_PUBLIC_USER)
sql plus> SELECT fcg, year, fcg_desc,
SUM(perm_asset) perm_asset,
SUM(perm_excess) perm_excess,
SUM(perm_deficit) perm_deficit,
SUM(all_perm_excess) all_perm_excess,
SUM(all_perm_deficit) all_perm_deficit,
SUM(temp_excess) temp_excess,
SUM(satisfy_rqmt) satisfy_rqmt
FROM summary_tab_dd
where year=2007
GROUP BY fcg, year, fcg_desc;
--execution plan
SELECT STATEMENT ALL_ROWS 12 291 17460
HASH(GROUP BY) 12 291 17460
MAT_VIEW REWRITE ACCESS(FULL) RPLANSWEB.MV_FCG_ALL_SUMMARY_TAB ANALYZED 11 291 17460 "MV_FCG_ALL_SUMMARY_TAB"."YEAR"=2007
--execution plan from sql workshop (application express)
SELECT STATEMENT 42,341 55 3,882 1,990,027
HASH GROUP BY 42,341 55 3,882 1,990,027
TABLE ACCESS FULL SUMMARY_TAB_DD 109,158 47 3,329 5,130,426 "YEAR" = 2007
--execution plan from an APEX page (displayed from v$sql and V$SQL_PLAN)
OPERATION: SELECT STATEMENT OPTIONS: OBJECT_NAME: OBJECT_ALIAS: OBJECT_TYPE: OPTIMIZER: ALL_ROWS SEARCH_COLUMNS: 0 COST: 4600 CARDINALITY: BYTES: CPU_COST: IO_COST: ACCESS_PREDICATES: FILTER_PREDICATES: PROJECTION:
OPERATION: HASH OPTIONS: GROUP BY OBJECT_NAME: OBJECT_ALIAS: OBJECT_TYPE: OPTIMIZER: SEARCH_COLUMNS: 0 COST: 4600 CARDINALITY: 109158 BYTES: 8732640 CPU_COST: 549150132 IO_COST: 4569 ACCESS_PREDICATES: FILTER_PREDICATES: PROJECTION: "FCG"[VARCHAR2,6], "FCG_DESC"[VARCHAR2,15], SUM("PERM_DEFICIT")[22], SUM("PERM_EXCESS")[22], SUM("SATISFY_RQMT")[22], SUM("TEMP_EXCESS")[22], SUM("ALL_PERM_EXCESS")[22], SUM("ALL_PERM_DEFICIT")[22], SUM("PERM_ASSET")[22]
OPERATION: TABLE ACCESS OPTIONS: FULL OBJECT_NAME: SUMMARY_TAB_DD OBJECT_ALIAS: SUMMARY_TAB_DD@SEL$1 OBJECT_TYPE: TABLE OPTIMIZER: SEARCH_COLUMNS: 0 COST: 3329
as you can see while executing the script in sql developer the optimizer is finding the relevant materialized view, not in the case of APEX's SQL Workshop or Page.
appreciate your time -
Hello all,
let me start by wishing you all the best for the forthcoming year !
And now, the problem
I am trying to create a materialized view so that a few slow reports that run on OBIEE (10g) make use of query rewrite functionality. Unfortunately any attempt that had made was unsuccessful. I though of posting the query that is created by OBIEE and the different materialized views that i have created, so that anyone that had a similar problem before might help me through it. So here it goes ( there is a separate discussion for the other query here ) :
First comes the query that was created by OBIEE when no materialized view existed.
SELECT DISTINCT D1.c5 AS c1, D1.c10 AS c2, D1.c9 AS c3, D1.c6 AS c4, D1.c8 AS c5, D1.c8 / NULLIF (D1.c6, 0) AS c6,
D1.c7 AS c7, D1.c7 / NULLIF (D1.c6, 0) AS c8, D1.c4 AS c9, D1.c3 / NULLIF (D1.c1, 0) AS c10, D1.c2 / NULLIF (D1.c1, 0) AS c11
FROM (SELECT SUM (D1.c6) OVER (PARTITION BY D1.c5) AS c1,
SUM (D1.c7) OVER (PARTITION BY D1.c5) AS c2,
SUM (D1.c8) OVER (PARTITION BY D1.c5) AS c3,
SUM (D1.c4) OVER (PARTITION BY D1.c5) AS c4,
D1.c5 AS c5, D1.c6 AS c6, D1.c7 AS c7, D1.c8 AS c8, D1.c9 AS c9, D1.c10 AS c10
FROM ( SELECT COUNT (CASE D1.c12 WHEN 1 THEN D1.c11 ELSE NULL END) AS c4, D1.c5 AS c5, SUM (D1.c13) AS c6,
SUM (D1.c14) AS c7, SUM (D1.c15) AS c8, COUNT (DISTINCT D1.c11) AS c9, D1.c10 AS c10
FROM (SELECT /*+ PARALLEL(T16913,8) */
T19403.YEAR_MONTH AS c5,
T7252.PERCENTAGE AS c10,
T366.BARCODE AS c11,
ROW_NUMBER () OVER ( PARTITION BY T19403.YEAR_MONTH, T366.BARCODE ORDER BY T19403.YEAR_MONTH DESC, T366.BARCODE DESC) AS c12,
T16913.PHA_QUANTITY AS c13,
T16913.EXEC_COST AS c14,
T16913.EXEC_VALUE AS c15
FROM EXECALENDAR_DIM T19403,
DRUG_DIM T366,
PERCENTAGE_DIM T7252,
PRESCDRUG_FACT T16913
WHERE (T366.DWHKEY = T16913.DRU_DWHKEY
AND T7252.DWHKEY = T16913.PER_DWHKEY
AND T16913.EXECUTION_DATE =
T19403.CALENDAR_DATE
AND T19403.YEAR_MONTH = '201212')) D1
GROUP BY D1.c5, D1.c10) D1) D1
ORDER BY c1, c2
so my first try was that
CREATE MATERIALIZED VIEW PRESCDRUG_FACT_MV BUILD IMMEDIATE REFRESH ON DEMAND ENABLE QUERY REWRITE AS
SELECT /*+ PARALLEL(PRESCDRUG_FACT,8) */
EXECALENDAR_DIM.YEAR_MONTH as YEAR_MONTH
,PRESCDRUG_FACT.PER_DWHKEY
,count(*) as COUNT_ALL
,COUNT (EXECALENDAR_DIM.YEAR_MONTH) AS c_YEAR_MONTH
,COUNT (DISTINCT PRESCDRUG_FACT.DRUG_CD) DRUG_CODE
,COUNT (DISTINCT PRESCDRUG_FACT.DRUG_BARCODE) BARCODE
-- quantities
,SUM (PRESCDRUG_FACT.PHA_QUANTITY) AS PHA_QUANTITY
,SUM (PRESCDRUG_FACT.DOC_QUANTITY) AS DOC_QUANTITY
,SUM (PRESCDRUG_FACT.APR_QUANTITY) AS APR_QUANTITY
-- values
,SUM (PRESCDRUG_FACT.EXEC_VALUE) AS EXEC_VALUE
,SUM (PRESCDRUG_FACT.PUB_VALUE) AS PUB_VALUE
,SUM (PRESCDRUG_FACT.APR_VALUE) AS APR_VALUE
-- costs
,SUM (PRESCDRUG_FACT.EXEC_COST) AS EXEC_COST
,SUM (PRESCDRUG_FACT.PUB_COST) AS PUB_COST
,SUM (PRESCDRUG_FACT.APR_COST) AS APR_COST
FROM EXECALENDAR_DIM, PRESCDRUG_FACT
WHERE EXECALENDAR_DIM.CALENDAR_DATE = PRESCDRUG_FACT.EXECUTION_DATE
AND EXECALENDAR_DIM.YEAR_MONTH in ( '201212')
GROUP BY EXECALENDAR_DIM.YEAR_MONTH ,PRESCDRUG_FACT.PER_DWHKEY
and i got the following messages from DBMS_MVIEW.EXPLAIN_REWRITE
QSM-01150: query did not rewrite
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, EXECALENDAR_DIM, on column, CALENDAR_DATE
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, EXECUTION_DATE
QSM-01082: Joining materialized view, PRESCDRUG_FACT_MV, with table, PRESCDRUG_FACT, not possible
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, DRU_DWHKEY
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, EXEC_VALUE
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, EXEC_COST
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, PHA_QUANTITY
QSM-01155: multi-mv query rewrite not possible when there is a Window Function
QSM-01219: no suitable materialized view found to rewrite this query
My second attempt is the following ( in comparison to the first i have added the DRUG_BARCODE column in the grouping clause
CREATE MATERIALIZED VIEW PRESCDRUG_FACT_MV BUILD IMMEDIATE REFRESH ON DEMAND ENABLE QUERY REWRITE AS
SELECT /*+ PARALLEL(PRESCDRUG_FACT,8) */
EXECALENDAR_DIM.YEAR_MONTH as YEAR_MONTH
,PRESCDRUG_FACT.PER_DWHKEY
,PRESCDRUG_FACT.DRUG_BARCODE
,count(*) as COUNT_ALL
,COUNT (EXECALENDAR_DIM.YEAR_MONTH) AS c_YEAR_MONTH
,COUNT (DISTINCT PRESCDRUG_FACT.DRUG_CD) DRUG_CODE
,COUNT (DISTINCT PRESCDRUG_FACT.DRUG_BARCODE) BARCODE
,COUNT (DISTINCT PRESCDRUG_FACT.PRESC_NUMBER) PRESC_NUMBER
,COUNT (DISTINCT PRESCDRUG_FACT.PRESC_ID) PRESC_ID
-- quantities
,SUM (PRESCDRUG_FACT.PHA_QUANTITY) AS PHA_QUANTITY
,SUM (PRESCDRUG_FACT.DOC_QUANTITY) AS DOC_QUANTITY
,SUM (PRESCDRUG_FACT.APR_QUANTITY) AS APR_QUANTITY
-- values
,SUM (PRESCDRUG_FACT.EXEC_VALUE) AS EXEC_VALUE
,SUM (PRESCDRUG_FACT.PUB_VALUE) AS PUB_VALUE
,SUM (PRESCDRUG_FACT.APR_VALUE) AS APR_VALUE
-- costs
,SUM (PRESCDRUG_FACT.EXEC_COST) AS EXEC_COST
,SUM (PRESCDRUG_FACT.PUB_COST) AS PUB_COST
,SUM (PRESCDRUG_FACT.APR_COST) AS APR_COST
FROM EXECALENDAR_DIM, PRESCDRUG_FACT
WHERE EXECALENDAR_DIM.CALENDAR_DATE = PRESCDRUG_FACT.EXECUTION_DATE
AND EXECALENDAR_DIM.YEAR_MONTH in ( '201212')
GROUP BY EXECALENDAR_DIM.YEAR_MONTH ,PRESCDRUG_FACT.PER_DWHKEY,DRUG_BARCODE
and the results of DBMS_MVIEW.EXPLAIN_REWRITE
QSM-01150: query did not rewrite
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, EXECALENDAR_DIM, on column, CALENDAR_DATE
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, EXECUTION_DATE
QSM-01082: Joining materialized view, PRESCDRUG_FACT_MV, with table, PRESCDRUG_FACT, not possible
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, DRU_DWHKEY
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, EXEC_VALUE
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, EXEC_COST
QSM-01102: materialized view, PRESCDRUG_FACT_MV, requires join back to table, PRESCDRUG_FACT, on column, PHA_QUANTITY
QSM-01155: multi-mv query rewrite not possible when there is a Window Function
QSM-01219: no suitable materialized view found to rewrite this query
third try (rolling up the group results)
CREATE MATERIALIZED VIEW PRESCDRUG_FACT_MV BUILD IMMEDIATE REFRESH ON DEMAND ENABLE QUERY REWRITE AS
SELECT /*+ PARALLEL(PRESCDRUG_FACT,8) */
EXECALENDAR_DIM.YEAR_MONTH as YEAR_MONTH
,PRESCDRUG_FACT.PER_DWHKEY
,PRESCDRUG_FACT.DRUG_BARCODE
,count(*) as COUNT_ALL
,COUNT (EXECALENDAR_DIM.YEAR_MONTH) AS c_YEAR_MONTH
,COUNT (DISTINCT PRESCDRUG_FACT.DRUG_CD) DRUG_CODE
,COUNT (DISTINCT PRESCDRUG_FACT.DRUG_BARCODE) BARCODE
,COUNT (DISTINCT PRESCDRUG_FACT.PRESC_NUMBER) PRESC_NUMBER
,COUNT (DISTINCT PRESCDRUG_FACT.PRESC_ID) PRESC_ID
-- quantities
,SUM (PRESCDRUG_FACT.PHA_QUANTITY) AS PHA_QUANTITY
,SUM (PRESCDRUG_FACT.DOC_QUANTITY) AS DOC_QUANTITY
,SUM (PRESCDRUG_FACT.APR_QUANTITY) AS APR_QUANTITY
-- values
,SUM (PRESCDRUG_FACT.EXEC_VALUE) AS EXEC_VALUE
,SUM (PRESCDRUG_FACT.PUB_VALUE) AS PUB_VALUE
,SUM (PRESCDRUG_FACT.APR_VALUE) AS APR_VALUE
-- costs
,SUM (PRESCDRUG_FACT.EXEC_COST) AS EXEC_COST
,SUM (PRESCDRUG_FACT.PUB_COST) AS PUB_COST
,SUM (PRESCDRUG_FACT.APR_COST) AS APR_COST
FROM EXECALENDAR_DIM, PRESCDRUG_FACT
WHERE EXECALENDAR_DIM.CALENDAR_DATE = PRESCDRUG_FACT.EXECUTION_DATE
AND EXECALENDAR_DIM.YEAR_MONTH in ( '201212')
GROUP BY EXECALENDAR_DIM.YEAR_MONTH , rollup (PRESCDRUG_FACT.PER_DWHKEY, DRUG_BARCODE)
results from DBMS_MVIEW.EXPLAIN_REWRITE
QSM-01150: query did not rewrite
QSM-01295: no suitable grouping_id found in materialized view with grouping sets
QSM-01155: multi-mv query rewrite not possible when there is a Window Function
QSM-01219: no suitable materialized view found to rewrite this query
So, no luck so far. My guess is that it has to do something with the partition clause that appears in the original query.
anyway, if anything cross your minds..
thanks in advance
TheodoreHello again,
It appeared that, the problem is present only when I try the query in pl/sql developer.
For some reason, even though I set QUERY_REWRITE_INTEGRITY to STALE_TOLERATED, it behaved as this parameter was set to ENFORCED.
So the case was that:
for session - STALE_TOLERATED
for system - ENFORCED
In v$parameter2 against "QUERY_REWRITE_INTEGRITY" was shown "stale_tolerated", but the query was not rewritten.
When I do the same (altering the session and perform the select query) in SQLPlus, everything works as expected - the query is rewritten.
And I conclude the problem is in PL/SQL Developer (my version is 8.0.1.1498) or something related to this.
Edited by: Verdi on 2010-2-12 14:00
Maybe you are looking for
-
iTunes said i needed to update my iPod then when it was done it deleted all of my content. All of my pictures, music, apps, and downloads are completely gone. I tried to go back to where i bought the songs but they have a price next to them, like i n
-
Hello to everyone!! First at all thanx. I am have a big problem with the check deposit. I am trying to use the transaction ff68 and i found a problem: After i introduce all the dates property, i try to save and i cant see after save the open files an
-
DBIF_DSQL2_CONNECTERR - direct link to DB
Hi all, I'm working on a SAP system in which we want to access directly to our DB (DB4, MSS) by an ABAP program. In transaction DBCO we made the entries for the two DB but when we try to execute the program the system returns the following e
-
[SOLVED] Slim theming help.
Im not sure if this is the right place to post this, but bare with me. Wishing to create a simple slim theme with black bacground and green text, i installed this theme: https://github.com/naglis/slim-minimal and replaced the bacground with a black o
-
The "javax." hierarchy is included with the SDK. As a result, I was wondering: why did Sun choose to create a separate root package for the classes in that heirarchy? I know that the "sun." packages are essentially Sun's playground and that Sun has a