Parallel Execution of Sub Queries using WITH clause ?
Hi ,
For the below query is it that Oracle Optimizer executes "sum_data" and "avg_data" queries parallely ?
WITH sum_data AS
SELECT deptno, sum(sal) AS S FROM emp GROUP BY deptno ),
avg_data AS
SELECT deptno, avg(sal) AS A FROM emp GROUP BY deptno )
SELECT sum_data.deptno, s, a, s / a FROM sum_data , avg_data
WHERE sum_data.deptno = avg_data.deptno
ORDER BY sum_data.deptno
THANKS
No, it doesn't.
You can add the parallel hint to each query itsel to speed up the exuction of a given query. But the WITH clause has nothing to do with parallel, it only uses temp or memory to keep the data being processed and thus speeds up the performance.
Edited by: DimaK on Feb 25, 2011 10:42 AM
Similar Messages
-
'Missing select' error for update statement using WITH clause
Hi,
I am getting the below error for update statement using WITH clause
SQL Error: ORA-00928: missing SELECT keyword
UPDATE A
set A.col1 = 'val1'
where
A.col2 IN (
WITH D AS
SELECT col2 FROM
(SELECT col2, MIN(datecol) col3 FROM DS
WHERE <conditions>
GROUP BY PATIENT) D2
WHERE
<conditions on A.col4 and D2.col3>Hi,
The format of a query using WITH is:
WITH d AS
SELECT ... -- sub_query
SELECT ... -- main query
You don't have a main query. The keyword FROM has to come immediately after the right ')' that ends the last WITH clause sub-query.
That explains the problem based on what you posted. I can't tell if the real problem is in the conditions that you didn't post.
I hope this answers your question.
If not, post a complete test script that people can run to re-create the problem and test their ideas. Include a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Construct a Sql block using With Clause to improve the performance
I have got four diff parametrized cursor in my Pl/Sql Procedure. As the performance of the Procedure is very pathetic,so i have been asked to tune the Select statements used in those cursors.
So I am trying to use the With Clause in order to club all those four Select Statements.
I would appreciate if anybody can help me to construct the Sql Block using With Clause.
My DB version is..
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
Four Diff cursors are defined below.
CURSOR all_iss (
b_batch_end_date IN TIMESTAMP,
IS
SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND ewo_no IN
(SELECT TO_CHAR(wo_no)
FROM MGO_PLANT_AUDIT
WHERE dml_status = 'U' OR dml_status = 'I')
UNION ALL
SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
b_batch_end_date;
CURSOR ewo_plant ( p_ewo_no IN IMPLMN_STEP_BREKPN.ewo_no%TYPE)
IS
SELECT DISTINCT wo_no ,
plant_code
FROM MGO_PLANT
WHERE TO_CHAR(wo_no) = p_ewo_no;
CURSOR iss_ewo_plnt (
p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
IS
SELECT *
FROM IMPLMN_STEP_BREKPN
WHERE issue_id = p_issue_id
AND ewo_no = p_ewo_no
AND
(plt_faclty_id = p_plnt_code
OR
plt_faclty_id IS NULL);
CURSOR iss_ewo_plnt_count (
p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
IS
SELECT COUNT(*)
FROM IMPLMN_STEP_BREKPN
WHERE issue_id = p_issue_id
AND ewo_no = p_ewo_no
AND
(plt_faclty_id = p_plnt_code
OR
plt_faclty_id IS NULL);Not tested. Some thing like below. i just made the queries as tables and given name as a,b,c and substituted columns for the parameters used in the 2nd cursor and third cursor. Try like this.
CURSOR all_iss (
b_batch_end_date IN TIMESTAMP,
IS
select a.*,b.*,c.* from
( SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND ewo_no IN
(SELECT TO_CHAR(wo_no)
FROM MGO_PLANT_AUDIT
WHERE dml_status = 'U' OR dml_status = 'I')
UNION ALL
SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
b_batch_end_date) a,
( SELECT DISTINCT wo_no ,
plant_code
FROM MGO_PLANT
WHERE TO_CHAR(wo_no) = p_ewo_no) b,
( SELECT *
FROM IMPLMN_STEP_BREKPN
WHERE issue_id = p_issue_id
AND ewo_no = p_ewo_no
plt_faclty_id IS NULL) c
where b.wo_no = c.ewo_no and
c.issue_id = a.issue_id ;
vinodh
Edited by: Vinodh2 on Jul 11, 2010 12:03 PM -
I have an update statement that is using the same suquery twice.
I am not usre if WITh clause be used in update statements?
Is there a way the below statement can be modified to use WITH clause?
UPDATE EMP_TRACKING_LIST L
SET ACTIVE_FLAG = DECODE((SELECT COUNT(*)
FROM EMP_TRACKING_LIST L2
WHERE L.NAME = L2.NAME AND
L.EMP_CODE = L2.EMP_CODE AND
L2.EMP_FLAG = 'Y'), 0, 'N', 'Y')
WHERE ACTIVE_FLAG != DECODE((SELECT COUNT(*)
FROM EMP_TRACKING_LIST L2
WHERE L.NAME = L2.NAME AND
L.EMP_CODE = L2.EMP_CODE AND
L2.EMP_ACTIVE_FLAG = 'Y'), 0, 'N', 'Y')
OR EMP_ACTIVE_FLAG IS NULL;
I would really appreciate your input
Edited by: user10937534 on Sep 2, 2009 4:47 PMHi,
WITH comes immediately before SELECT, not before UPDATE.
To use WITH in an UPDATE statement, you would say something like:
UPDATE EMP_TRACKING_LIST L
SET ACTIVE_FLAG =
WITH sub_q AS
SELECT ...
SELECT ...
FROM sub_q ...
;I don't think there's any way to use values from the sub-query in the WHERE clause of the UPDATE statement itself; MERGE is a much better bet for eliminating redundancy there.
Sorry, I'm not at a database now, so I can test anything. -
I am using the sql with following construct , the explain plan doesn't show that index on col1 of tab1 (used in with clause) as used- it just shows a full table access of a view (system) - result set of query in with clause.
1. Is it that oracle will not use that index or it doesn't show up
2. If so then is it good to have that table in join of all the three sqls that i am doing union - atleast in that case the index on col1 gets used (per explain plan).
with sql1 ( select * from tab1 where col1 = 'y')
select col_gen
from tab2 a, sql1 b
where a.col3 = b.col3
union
select col_gen
from tab3 a, sql1 b
where a.col3 = b.col4
Union
select col_gen
from tab4 a, sql1 b
where a.col3 = b.col4WITH tab1 AS ( SELECT * FROM tab12 WHERE SESSION_ID = '12')
SELECT DISTINCT b.unit_key unit_key ,NULL colabc1_KEY ,NULL colabc3_KEY,a.col3_ID
FROM tab1_col31_MAP a, tab1 b
WHERE a.unit_id = b.unit_id
UNION
SELECT DISTINCT NULL unit_key ,b.colabc1_KEY colabc1_KEY,NULL colabc3_KEY,a.col3_ID
FROM tab2_col32_MAP a,tab1 b
WHERE a.colabc1_id = b.colabc1_id
UNION
SELECT DISTINCT NULL unit_key,NULL colabc2_KEY,b.colabc3_KEY colabc3_KEY,a.col3_ID
FROM tab1_col33 a, tab1 b
WHERE a.colabc3_id = b.colabc3_id
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE
RECURSIVE EXECUTION SYS_LE_2_0
TEMP TABLE TRANSFORMATION
SORT UNIQUE
UNION-ALL
NESTED LOOPS
VIEW
TABLE ACCESS FULL SYS_TEMP_0FD9D6603_53EE226
INDEX RANGE SCAN SYS_C00133240
NESTED LOOPS
VIEW
TABLE ACCESS FULL SYS_TEMP_0FD9D6603_53EE226
INDEX RANGE SCAN SYS_C00133205
NESTED LOOPS
VIEW
TABLE ACCESS FULL SYS_TEMP_0FD9D6603_53EE226
INDEX RANGE SCAN SYS_C00133202
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SELECT * FROM tab12 WHERE SESSION_ID = '12'
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Optimizer Mode=CHOOSE
TABLE ACCESS BY INDEX ROWID tab12
INDEX RANGE SCAN IDX
Will the temp table transformation use the index used in the query above (ie. IDX) -
SSRS Execution Account cannot be used with Report Builder
Running SQL Server 2012 SP2, I have specified an Execution Account in Reporting Services Configuration Manager as described here: http://msdn.microsoft.com/en-us/library/ms156302(v=sql.110).aspx
The article states: "You can specify Integrated Security=SSPI if the database server supports Windows integrated security and the account used for unattended report processing has permission to read the database." I have created a data source using
the Report Manager Web interface with connection string: "Data Source=<server>;Initial Catalog=<database>;Integrated Security=SSPI" and "Connect using: Credentials are not required" option.
The Execution Account is a domain user account with db_owner membership on the database in question. When I "Test Connection" in Report Manager, the connection is created successfully.
However, when I attempt to create a new dataset using this data source in Report Builder, I am unable to connect to the data source: "You have specified integrated security or credentials in the connection string for the data source, but the data source
is configured to use a different credential type. To use the values in the connection string, you must configure the unattended report processing account for the report server."
If I change the "connect using" option for the data source to "Windows integrated security" I can successfully create a new dataset and report in Report Builder. After saving the report, I reconfigure the data source for "Credentials
are not required" and I am able to successfully run the report using the Execution Account.
Is this a known limitation? The Report Builder cannot be used with an unattended Execution Account configured?Hi desmondgc,
According to your description, you have set the execution account for connecting data source. You can connect data source successfully, but can't create dataset with the unattended account. Right?
As we tested in our local environment, we encountered the same issue. Even testing connection successfully in Report Builder, it still says unable connect to data source when creating dataset.
For this issue, I would recommend to submit it to the Microsoft Connect at this link
https://connect.microsoft.com/SQLServer/Feedback.
This connect site will serve as a connecting point between you and Microsoft, and ultimately the large community for you and Microsoft to interact with. Your feedback enables Microsoft to offer the best software and deliver superior services, meanwhile you
can learn more about and contribute to the exciting projects on Microsoft Connect.
We will keep you updated if we find something, thank you for your posting.
Best Regards,
Simon Hou -
Using WITH clause in Pro*Cobol
Hi!
I am trying to improve the performance of a query by introducing WITH clause.
The query is in Pro*Cobol Release 9.2.0.6.0 - Production.
I got compilation error
WITH DPTCOST AS (
...............1
PCB-S-00400, Encountered the symbol "DPTCOST" when expecting one of the following:
END-EXEC
....continued
So I wonder if we could use that clause at all with Pro*Cobol
Here is the excerp of the code
EXEC SQL
DECLARE INPUT_ACTUAL CURSOR FOR
WITH DPTCOST AS (
SELECT /*+ rule */
A.CODE_COMBINATION_ID,
A.SEGMENT1, A.SEGMENT2, A.SEGMENT3,
A.SEGMENT6,
D.COSTING, D.PROCESS,
D.MTL_CODE, D.FACTOR
FROM
GL_CODE_COMBINATION A,
ALCGL_DEPARTMENT_COSTINGS D
WHERE
A.TEMPLATE_ID IS NULL
AND A.SUMMARY_FLAG <> 'Y'
AND A.SEGMENT1 = D.PLANT_NUMBER
AND A.SEGMENT3 <> '6999001'
AND A.SEGMENT3 <> '6999002'
AND SUBSTR(A.SEGMENT2,4,3) = D.DEPARTMENT
AND D.ACTUAL_FLAG = 'A'
) ... continuedMaterialized views are basically stored query results. They offer advanced functionality like query rewrite, refresh on commit, and more;
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6002.htm
Unlike a view, they actually store the results of the query - not just the query;
SQL> create table t (cid number primary key)
Table created.
SQL> insert into t select object_id from dba_objects where object_id is not null
12791 rows created.
SQL> create materialized view mv
as select * from t
Snapshot created.
SQL> select object_name, object_type from user_objects where object_name ='MV'
OBJECT_NAME OBJECT_TYPE
MV TABLE
MV MATERIALIZED VIEW
2 rows selected.
SQL> select segment_name, bytes from user_segments where segment_name in ('T', 'MV')
SEGMENT_NAME BYTES
T 196608
MV 196608
2 rows selected.Temporary tables are simply tables that are created then dropped. GLOBAL TEMPORARY TABLES have the advantage (or disadvantage) of only existing until commit or the end of the session. They results are visible to the user that inserted the data - but only temporarily;
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#sthref7483 -
Syntax help needed in update using 'WITH' Clause
Update CP_JP_CORP_FSASA_FEEDUPLOAD_r r
set (
gfrn,
tenor_code,
tenor_description,
exposure_category,
frr,
facility_classification,
limit_amount,
limit_usd,
approval_ccy,
approval_date,
expiry_date,
avail_status_code,
avail_status_desc,
revolving_indicator,
committed_flag,
committed_until_date,
committed_amount,
advised_flag,
advised_amount,
facility_long_description,
booking_unit_code,
extending_unit_code,
extending_unit_short_desc,
approving_unit_code,
approving_unit_short_des,
transaction_type,
branch_no
=
With t as
Select fac.gfrn,fac.tenor_code,fac.tenor_description,fac.exposure_category,fac.frr,
fac.facility_classification,fac.limit_amount,fac.limit_usd,fac.approval_ccy,
fac.approval_date,fac.expiry_date,fac.avail_status_code,fac.avail_status_desc,
fac.revolving_indicator,fac.committed_flag,fac.committed_until_date,fac.committed_amount,
fac.advised_flag,fac.advised_amount,fac.facility_long_description,fac.booking_unit_code,
fac.extending_unit_code,fac.extending_unit_short_desc,fac.approving_unit_code,fac.approving_unit_short_des,
/*'Check' normalflag,
cust.adjusted_orr fsasaorr1stborrower,
'Normal' category1stborrower,
cust.adjusted_orr fsasaorr2ndborrower,
'Normal' category2ndborrower,
cust.adjusted_orr fsasaorrfinal,
'Normal' categoryfinal */
txn.transaction_type,txn.branch_no,txn.gfcid,txn.transaction_id
from cp_fsa_boj_corp_cr_fac_hist fac,
--cp_fsa_boj_corp_cr_cust_hist cust,
cp_fsa_boj_corp_cr_txn_hist txn
where fac.gfcid = txn.gfcid
and fac.facility_id = txn.facility_id
and fac.as_of_date = txn.as_of_date
and to_char(fac.as_of_date,'yyyymm') = p_financial_period
and fac.as_of_date = last_day(fac.as_of_date)
select t.gfrn,
t.tenor_code,
t.tenor_description,
t.exposure_category,
t.frr,
t.facility_classification,
t.limit_amount,
t.limit_usd,
t.approval_ccy,
t.approval_date,
t.expiry_date,
t.avail_status_code,
t.avail_status_desc,
t.revolving_indicator,
t.committed_flag,
t.committed_until_date,
t.committed_amount,
t.advised_flag,
t.advised_amount,
t.facility_long_description
t.booking_unit_code,
t.extending_unit_code,
t.extending_unit_short_desc,
t.approving_unit_code,
t.approving_unit_short_des,
t.transaction_type,
t.branch_no
from t
where r.financialperiod = p_financial_period
and exists
Select 1
from t
where t.transaction_id = r.ce_trans_id
)I'm facing syntax problemHii All,
This is my actual update.(I stopped performing dml operations in cursors following Karthick Arp) :-)
Update CP_JP_CORP_FSASA_FEEDUPLOAD_r r
set (
gfrn,
tenor_code,
tenor_description,
exposure_category,
frr,
facility_classification,
limit_amount,
limit_usd,
approval_ccy,
approval_date,
expiry_date,
avail_status_code,
avail_status_desc,
revolving_indicator,
committed_flag,
committed_until_date,
committed_amount,
advised_flag,
advised_amount,
facility_long_description,
booking_unit_code,
extending_unit_code,
extending_unit_short_desc,
approving_unit_code,
approving_unit_short_des,
transaction_type,
branch_no
= (
Select fac.gfrn,fac.tenor_code,fac.tenor_description,fac.exposure_category,fac.frr,
fac.facility_classification,fac.limit_amount,fac.limit_usd,fac.approval_ccy,
fac.approval_date,fac.expiry_date,fac.avail_status_code,fac.avail_status_desc,
fac.revolving_indicator,fac.committed_flag,fac.committed_until_date,fac.committed_amount,
fac.advised_flag,fac.advised_amount,fac.facility_long_description,fac.booking_unit_code,
fac.extending_unit_code,fac.extending_unit_short_desc,fac.approving_unit_code,fac.approving_unit_short_des,
txn.transaction_type,txn.branch_no
from cp_fsa_boj_corp_cr_fac_hist fac,
--cp_fsa_boj_corp_cr_cust_hist cust,
cp_fsa_boj_corp_cr_txn_hist txn
where fac.gfcid = txn.gfcid
and fac.facility_id = txn.facility_id
and fac.as_of_date = txn.as_of_date
and to_char(fac.as_of_date,'yyyymm') = p_financial_period
and fac.as_of_date = last_day(fac.as_of_date)
where Exists
Select 1
from cp_fsa_boj_corp_cr_fac_hist fac,
cp_fsa_boj_corp_cr_txn_hist txn
where fac.gfcid = txn.gfcid
and fac.facility_id = txn.facility_id
and fac.as_of_date = txn.as_of_date
and to_char(fac.as_of_date,'yyyymm') = p_financial_period
and fac.as_of_date = last_day(fac.as_of_date)
and txn.transaction_id = r.ce_trans_id
)Now in my update I'm using same 'SELECT' twice once in 'SET' and again in 'EXISTS' clause. I'd like to make use of 'WITH' Clause and avoid unnecessary 'SELECT' . Please help me. -
How to use "with clause query" in DBadapter
Hi all,
I need to implement a "with clause" query in oracle soa 11g bpel. When i put the query in db adapter in pure sql, the schema is not getting generated properly. Can any one suggest a solution to my problem.
Regards,
KaushikPure SQL won't work because it is expecting the first word in the SQL to be SELECT (or INSERT,UPDATE,DELETE).
If your query is WITH ... SELECT ...
try this:
delete everything before SELECT. Copy and paste the generated XSD to another window. The SQL test may fail, but that will just mean that it couldn't fill in the types of the columns in the SELECT ... FROM list. You can always do that yourself by hand editing the XSD (including in the wizard before you hit next). Then put back the WITH ... clause before the remaining SELECT .... If the XSD gets overwritten, copy the version you saved in the other window and paste it over top. Then hit next and the runtime should still work.
Keep in mind that SQL is very complex and hard to fully parse in the UI. However the minimum information the DbAdapter needs is quite limited; basically just the name and number of columns that are coming back. The XSD is meant to be editable in the wizard if the SQL is too complex.
Thanks
Steve -
Using full outer join of subqueries named using with clause
Hi,
I am trying to create a view which is having 2 subqueries vol1 & vol2 with WITH clause. I am joining those 2 subqueries in the main query with FULL OUTER JOIN.
When i compile that view in a tool like pl/sql developer, It has been compiled successfully.
But when i call the view creation script from SQL command prompt, It is throwing error as
from vol1 FULL JOIN vol2 o ON (vol1.ct_reference = vol2.ct_reference and vol1.table_name = vol2.table_name
ERROR at line 29:
ORA-00942: table or view does not exist
Kindly advise whats going wrong.that's line 29. Maybe you get a better idea if you strip your operation of all the unneccessary elements until it works.
There are some known bugs with subquery factoring (aka with clause) and also with ANSI join syntax, but it is hard to tell what happens here based on your description. But one thing is strange - if it is not a result of formatting (not formatting): I would expect the asterisk beneath the unknown table and not beneath the key word FULL.
P.S.: my editor makes me think it's rather a proportional font thing. Have I already said that I don't like proportional font for SQL code examples? -
Hi all,
I am getting ORA-00928 error [missing SELECT statement] when running below statement.
Is 'WITH' clause allow in PLSQL?
-- Created on 26/12/2007
declare
-- Local variables here
i integer;
begin
-- Test statements here
WITH x AS (
SELECT /*+materialize*/ *
FROM ALL_OBJECTS
WHERE LAST_DDL_TIME > SYSDATE-1
INSERT INTO tmp1
SELECT *
FROM x;
end;wrong syntax, you need this....
ME_XE?create table tmp1 as select * from all_objects where 1=0;
Table created.
Elapsed: 00:00:00.21
ME_XE?create table x as select * from all_objects where rownum < 10;
Table created.
Elapsed: 00:00:00.51
ME_XE?declare
2 -- Local variables here
3 i integer;
4 begin
5 INSERT INTO tmp1
6 WITH x AS (
7 SELECT /*+materialize*/ *
8 FROM ALL_OBJECTS
9 WHERE LAST_DDL_TIME > SYSDATE-1
10 )
11 SELECT *
12 FROM x;
13 end;
14 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.15
ME_XE? -
Ssis 2012 parallel execution of ssis packages using catalog database hangs
i have a simple ssis package in 2012 where I am executing several data flow tasks in parallel using sequence containers, however very often the sql job just runs forever although all the tables have been loaded or I cant see whats going on, the job neither
fails nor succeeds, just goes on executing,is there an issue with executing several data flow tasks in parallel, why does the job continue to run forver, how to troubleshoot and fix the error, please guide, are there any issues using the catalog db execution,
is that the reason this behavior is showing?multiple execute sql tasks within sequence containers running to execute the ssis packages deployed in ssisdb in sunchronous mode using the catalog database execution model
all of the ssis packages that have the data flow taks retrieve data from source to 3 different tables.
some of them push data into the same table.
please let me know if you need more information.
the job just runs forever, looks like all the data flow tasks ran and it is still running, because I don't see an increase in the row count of the tables, I may be wrong, if I check the execution status, 1 task does not show as succeeded, I don't know why
thanks a lot for ur help, ur help is much appreciated nik -
Temp start transformation using "with"clause
I'm experiencing a very strange problem. I wrote the SQL below and when I execute through toad and sqlplus, oracle makes the star transformation, but when I execute it through C, it doens't makes the transformation. Any help are welcome.
WITH a AS
(SELECT /*+ materialize use_hash(c,p,c3) */
c.parent_account_no, c.package_id, c3.siebel_instance_id
FROM cmf_package c, package_definition_values p,
cmf_packages_fat3c c3
WHERE c.inactive_dt IS NULL
AND c.package_inst_id = c3.package_instance_id
AND c.package_inst_id_serv = c3.package_instance_id_serv
AND c.package_id = p.package_id
AND p.short_display IS NULL)
SELECT /*+ leading(c ) push_subq use_hash(acr,pdv,cpcp3,ciam,c) */
'PACK_VOZ_DUP', cp.parent_account_no, ciam.external_id, c.bill_period,
cp3.siebel_instance_id, cp.package_id, acr.is_business,
TO_NUMBER (NULL), 1, c.bill_state, 'SI', acr.ROWID, pdv.ROWID,
cp.ROWID, cp3.ROWID, ciam.ROWID, c.ROWID
FROM account_category_ref acr,
package_definition_values pdv,
cmf_package cp,
cmf_packages_fat3c cp3,
customer_id_acct_map ciam,
cmf c
WHERE pdv.short_display IS NULL
AND pdv.package_id = cp.package_id
AND cp.inactive_dt IS NULL
AND cp.parent_account_no = c.account_no
AND c.account_category = acr.account_category
AND c.account_no = ciam.account_no
AND ciam.external_id_type = 14
AND ciam.is_current = 1
AND cp.package_inst_id = cp3.package_instance_id
AND cp.package_inst_id_serv = cp3.package_instance_id_serv
AND cp3.siebel_instance_id IS NOT NULL
AND EXISTS (
SELECT /*+ hash_sj */
1
FROM a c3
WHERE c3.parent_account_no = cp.parent_account_no
AND c3.package_id <> cp.package_id
AND c3.siebel_instance_id = cp3.siebel_instance_id)
explain from Toad
Plan
SELECT STATEMENT CHOOSECost: 199,074 Bytes: 188 Cardinality: 1
15 TEMP TABLE TRANSFORMATION
14 HASH JOIN SEMI Cost: 199,074 Bytes: 188 Cardinality: 1
11 HASH JOIN Cost: 191,234 Bytes: 111,173,166 Cardinality: 726,622
9 HASH JOIN Cost: 162,751 Bytes: 108,444,416 Cardinality: 847,222
7 HASH JOIN Cost: 159,088 Bytes: 217,362,656 Cardinality: 1,940,738
5 HASH JOIN Cost: 134,635 Bytes: 108,065,443 Cardinality: 1,367,917
3 HASH JOIN Cost: 121,145 Bytes: 127,501,647 Cardinality: 2,712,801
1 TABLE ACCESS FULL ARBOR.CMF Cost: 117,431 Bytes: 179,044,800 Cardinality: 5,425,600
2 TABLE ACCESS FULL ARBOR.ACCOUNT_CATEGORY_REF Cost: 4 Bytes: 518 Cardinality: 37
4 TABLE ACCESS FULL ARBOR.CUSTOMER_ID_ACCT_MAP Cost: 9,229 Bytes: 87,546,656 Cardinality: 2,735,833
6 TABLE ACCESS FULL ARBOR.CMF_PACKAGE Cost: 17,299 Bytes: 254,003,970 Cardinality: 7,697,090
8 TABLE ACCESS FULL ARBOR.PACKAGE_DEFINITION_VALUES Cost: 6 Bytes: 10,992 Cardinality: 687
10 TABLE ACCESS FULL TELEMAR.CMF_PACKAGES_FAT3C Cost: 17,248 Bytes: 419,471,250 Cardinality: 16,778,850
13 VIEW ARBOR. Cost: 3,638 Bytes: 116,664,100 Cardinality: 3,333,260
12 TABLE ACCESS FULL SYS.SYS_TEMP_0FD9D660C_D8362B9 Cost: 3,638 Bytes: 66,665,200 Cardinality: 3,333,260
explain from C
Plan
SELECT STATEMENT CHOOSECost: 631,186,428
19 FILTER
11 HASH JOIN Cost: 189,620 Bytes: 5,558,643 Cardinality: 36,331
9 HASH JOIN Cost: 189,425 Bytes: 11,401,688 Cardinality: 83,224
7 HASH JOIN Cost: 159,088 Bytes: 217,362,656 Cardinality: 1,940,738
5 HASH JOIN Cost: 134,635 Bytes: 108,065,443 Cardinality: 1,367,917
3 HASH JOIN Cost: 121,145 Bytes: 127,501,647 Cardinality: 2,712,801
1 TABLE ACCESS FULL ARBOR.CMF Cost: 117,431 Bytes: 179,044,800 Cardinality: 5,425,600
2 TABLE ACCESS FULL ARBOR.ACCOUNT_CATEGORY_REF Cost: 4 Bytes: 518 Cardinality: 37
4 TABLE ACCESS FULL ARBOR.CUSTOMER_ID_ACCT_MAP Cost: 9,229 Bytes: 87,546,656 Cardinality: 2,735,833
6 TABLE ACCESS FULL ARBOR.CMF_PACKAGE Cost: 17,299 Bytes: 254,003,970 Cardinality: 7,697,090
8 TABLE ACCESS FULL TELEMAR.CMF_PACKAGES_FAT3C Cost: 17,248 Bytes: 419,471,250 Cardinality: 16,778,850
10 TABLE ACCESS FULL ARBOR.PACKAGE_DEFINITION_VALUES Cost: 6 Bytes: 10,992 Cardinality: 687
18 HASH JOIN Cost: 17,368 Bytes: 53 Cardinality: 1
13 TABLE ACCESS BY INDEX ROWID ARBOR.CMF_PACKAGE Cost: 5 Bytes: 312 Cardinality: 12
12 INDEX RANGE SCAN ARBOR.CMF_PACKAGE_XCP_ACCOUNT_NO_KEY Cost: 3 Cardinality: 1
17 MERGE JOIN CARTESIAN Cost: 17,362 Bytes: 345,222 Cardinality: 12,786
14 TABLE ACCESS FULL TELEMAR.CMF_PACKAGES_FAT3C Cost: 17,248 Bytes: 342 Cardinality: 19
16 BUFFER SORT Cost: 114 Bytes: 6,183 Cardinality: 687
15 TABLE ACCESS FULL ARBOR.PACKAGE_DEFINITION_VALUES Cost: 6 Bytes: 6,183 Cardinality: 687
Thanks in advanced.fbucco wrote:
I'm experiencing a very strange problem. I wrote the SQL below and when I execute through toad and sqlplus, oracle makes the star transformation, but when I execute it through C, it doens't makes the transformation. Any help are welcome.
Neither plan shows a "star" transformation - did you mean "temp table" transformation ?
It looks as if your C wrapper has taken out your materialize hint (among others).
Which version of Oracle are you using, by the way ? Is it the same in all cases, and is the client the same version as the server in all cases.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
"Science is more than a body of knowledge; it is a way of thinking"
Carl Sagan -
On Parallel Execution of SQL Queries
Hi All,
We have forced Parallel hint in a query and if its without any where clause it uses parallel hint but where as if we add few where clauses it goes through few indexes and does not show parallel hint in the explain plan. Is it because we need to make those indexes also parallel and run the query once more or am i missing something here.
But even i had tried making the index parallel enabled and checked it. Database Version 10.2.0.1.0 Enterprise Edition 64 Bit mounted on Linux.
PRO's Please helpramarun wrote:
Hi All,
We have forced Parallel hint in a query and if its without any where clause it uses parallel hint but where as if we add few where clauses it goes through few indexes and does not show parallel hint in the explain plan. Is it because we need to make those indexes also parallel and run the query once more or am i missing something here.
But even i had tried making the index parallel enabled and checked it. Database Version 10.2.0.1.0 Enterprise Edition 64 Bit mounted on Linux.
PRO's Please helpPARALLEL can make some SQL slower.
if PARALLEL was always better, why does not Oracle enable it by default? -
Materialize a Subquery without using "with" clause
Hi experts,
We know that we can materialize a subquery as below :
with sub_q as
( select /*+ materialize */ a,b,c from table_name )
select * from sub_q;
My question is, is there any other way to force a subquery be materialized by writing straight as below ?:
select * from
( select a,b,c from table_name );
Thanks in advance.user503699 wrote:
You sure about that? I don't think so. ;)??? Do you understand what materialize is? I don't think so. Feel the difference:
SQL> create table emp1 as select * from emp
2 /
Table created.
SQL> explain plan for
2 with t as (
3 select /*+ materialize */ * from emp1 where deptno = 10
4 )
5 select * from t where job = 'CLERK'
6 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 481100556
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3 | 261 | 5 (0)| 00:00:01 |
| 1 | TEMP TABLE TRANSFORMATION | | | | | |
| 2 | LOAD AS SELECT | | | | | |
|* 3 | TABLE ACCESS FULL | EMP1 | 3 | 261 | 3 (0)| 00:00:01 |
|* 4 | VIEW | | 3 | 261 | 2 (0)| 00:00:01 |
| 5 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6608_11C6B35 | 3 | 261 | 2 (0)| 00:00:01 | <== SYS_TEMP_0FD9D6608_11C6B35 is a metrialized table t
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - filter("DEPTNO"=10)
4 - filter("JOB"='CLERK')
Note
- dynamic sampling used for this statement
22 rows selected.
SQL> explain plan for
2 select * from (select /*+ materialize */ * from emp1 where deptno = 10) t where job = 'CLERK'
3 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 2226897347
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 87 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP1 | 1 | 87 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("EMP1"."JOB"='CLERK' AND "DEPTNO"=10)
Note
- dynamic sampling used for this statement
17 rows selected.
SQL> SY
Maybe you are looking for
-
Changing the default "New Item" link url in SharePoint
Is it possible to change the default url of the New Item button on a list. When i hover over or click on new item link it show the ......../15/listform.aspx?Page type=blah.....blah...... I want it to be something like :/newform?source=xxxx Please hel
-
How can I get SQL Developer working on Windows 7 64-bit
Hi all, I've followed the download instructions for SQL Developer v4 as per the download page ( http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/sqldev-download-v4-1925679.html Install instructions: http://www.oracle.com/tech
-
How to combine two datatable in c#}
Hi Everybody, I have two datatables I want to combine single output. First datatable1 result A1 A2 10 15 Second datatable2 result B1 B2 5 10 The final result should be in datatable3 A1 A2 B1 B2 10 15 5 10
-
I cant remember the answers to my security questions..how can i reset it???
-
Dear friends, When I click on log off button in portal (with firefox browser), it does nothing. Does anyone know how to fix this issue? Log off does work fine with I.E. We are on EP6 SP13 Patch 2. Thanks and Regards, Mandar