Required query perfomance tuning which has START WITH CONNECT BY PRIOR
Hi,
I have below small query and the CDDS table with 40+ million records.
SELECT -LEVEL, COMPONENT_ID, COMPONENT_TYPE, COMPONENT_STATUS,
PARENT_COMPONENT_ID, PARENT_COMPONENT_TYPE, other_info
BULK COLLECT INTO ltbl_cdds_rec
FROM CDDS
START WITH
PARENT_COMPONENT_ID IN
( SELECT dns_name
FROM RAS_CARD
WHERE ras_name = <<INPUT_PARAMATER>>
AND parent_component_type = 'CT_NRP')
CONNECT BY PARENT_COMPONENT_ID = PRIOR COMPONENT_ID;
To process this query, its taking 3 hours.
Please suggest the way forward to tune the query for better performance.
Create statement for CDDS:
CREATE TABLE CDDS
COMPONENT_TYPE VARCHAR2(30 BYTE),
COMPONENT_ID VARCHAR2(255 BYTE),
PARENT_COMPONENT_TYPE VARCHAR2(30 BYTE),
PARENT_COMPONENT_ID VARCHAR2(255 BYTE),
COMPONENT_VERSION_NO VARCHAR2(30 BYTE),
COMPONENT_STATUS VARCHAR2(30 BYTE),
ODS_CREATE_DATE DATE,
ODS_LAST_UPDATE_DATE DATE,
OTHER_INFO VARCHAR2(255 BYTE)
TABLESPACE APPL_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
NOMONITORING
ENABLE ROW MOVEMENT;
Create statement for RAS_CARD:
CREATE TABLE RAS_CARD
RAS_NAME VARCHAR2(20 BYTE),
SLOT VARCHAR2(2 BYTE),
RAS_CARD_ID VARCHAR2(30 BYTE),
CARD_TYPE VARCHAR2(5 BYTE),
IP_ADDRESS VARCHAR2(15 BYTE),
DNS_NAME VARCHAR2(255 BYTE),
STATUS VARCHAR2(15 BYTE),
NRP_NO CHAR(2 BYTE),
NRP_TOTAL_ALLOC_CAPACITY NUMBER(10),
CREATED_BY VARCHAR2(10 BYTE),
NRP_ALLOCATED_CAPACITY NUMBER(10),
NIDB_DRA2_KEY VARCHAR2(15 BYTE),
NIDB_DRN1_KEY CHAR(6 BYTE),
ODS_CREATE_DATE DATE,
LAST_UPDATED_BY VARCHAR2(10 BYTE),
ODS_LAST_UPDATE_DATE DATE,
WATERMARK NUMBER(38)
TABLESPACE APPL_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 1M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOLOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
NOMONITORING;
Explain Plan for the below query:
select * from CDDS
where PARENT_COMPONENT_ID IN
( SELECT dns_name
FROM RAS_CARD
WHERE ras_name = <<INPUT_PARAMATER>>
| Id | Operation | Name | Rows | Bytes | Cost | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 107 | 12 | | |
| 1 | TABLE ACCESS BY INDEX ROWID| CDDS | 1 | 62 | 1 | | |
| 2 | NESTED LOOPS | | 1 | 107 | 12 | | |
| 3 | SORT UNIQUE | | | | | | |
|* 4 | TABLE ACCESS FULL | RAS_CARD | 4 | 180 | 6 | | |
| 5 | PARTITION RANGE ITERATOR | | | | | KEY | KEY |
|* 6 | INDEX RANGE SCAN | CDDS_I02 | 10 | | 1 | KEY | KEY |
---------------------------------------------------------------------------------------------
Similar Messages
-
Creating a template in Pages is straight-forward as answered here previously. Is there an equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template? This has proved unsatisfactory to me so far. Lines are left in etc.
There are two basic menus for fonts - one from the main menu bar and one from the toolbar. You can also bring up the font manage dialog.
I don't recommend trying to hard to force an otherwise foreign font, as it inevitably needs to be usable/supported on iOS as well, and that can get tricky w/3rd party fonts, as an example, even with the expanded font support in the latest iBA.
If you need to discuss fonts more, I suggest starting a new thread....preferably with a slightly more brief title, thanks. -
Hi.
I have data in a table which looks like:
Top level Step 3rd Level 4th Level Script Name
NORMAL_DAY Step 1 of NORMAL_DAY DATE_FEEDER Step 1 of DATE_FEEDER INT_EOD_DATE_FEEDER
NORMAL_DAY Step 2 of NORMAL_DAY EOD_FX_RATE_UPLOAD Step 3 of EOD_FX_RATE_UPLOAD SEND_MAIL_FXSPOTS
NORMAL_DAY Step 2 of NORMAL_DAY EOD_FX_RATE_UPLOAD Step 2 of EOD_FX_RATE_UPLOAD FXSPOTS
NORMAL_DAY Step 2 of NORMAL_DAY EOD_FX_RATE_UPLOAD Step 1 of EOD_FX_RATE_UPLOAD FX_FTPS_GET_EOD
NORMAL_DAY Step 3 of NORMAL_DAY CALENDAR_UPLOAD Step 1 of CALENDAR_UPLOAD CALENDAR
NORMAL_DAY Step 3 of NORMAL_DAY CALENDAR_UPLOAD Step 2 of CALENDAR_UPLOAD MDS_STOP
NORMAL_DAY Step 3 of NORMAL_DAY CALENDAR_UPLOAD Step 3 of CALENDAR_UPLOAD MDS_HOLIDAY
NORMAL_DAY Step 3 of NORMAL_DAY CALENDAR_UPLOAD Step 4 of CALENDAR_UPLOAD MDS_START
NORMAL_DAY Step 4 of NORMAL_DAY FA_VALUATIONS Step 1 of FA_VALUATIONS IMPORTMTM
NORMAL_DAY Step 4 of NORMAL_DAY FA_VALUATIONS Step 2 of FA_VALUATIONS INT_EOD_VALUATIONS
As you can see, it lends itself to a tree type structure. I am trying to display this information using the start with/connect by clauses.....
My initial query looks like:
select main.name "Top Level",
level2.name "Step",
level3.name "3rd Level",
level4.name "4th Level",
level5.name "Script Name",
level5.run_start,
level5.run_end,
(level5.run_end - level5.run_start) "Time difference",
to_char((level5.run_end - level5.run_start),'99999999999999999999999999990.0000000000')*1000 as Total_Run_Time
from jcs_jobs main,
jcs_jobs level2,
jcs_jobs level3,
jcs_jobs level4,
jcs_jobs level5
where main.name = 'NORMAL_DAY'
and main.PARENT_JOB_ID IS NULL
and main.job_id = 2253800
and main.job_id = level2.parent_job_id
and level2.job_id = level3.parent_job_id
and level3.job_id = level4.parent_job_id
and level4.job_id = level5.parent_job_id
order by level2.step_name;
This is a bit restrictive, so I need to make it more generic, because we can actually have more than 5 levels of depth.....
I haven't included the time element in the sample data. This also appears to be another conundrum.....how to display milliseconds in a reasonable date format?
Thank you very much in advance!
Devtry this way:
SQL> select script_name, job,
2 to_char(to_date(run_start,'Jhh24miss'),'dd-mon-yyyy hh24:mi:ss') run_start,
3 to_char(to_date(run_end,'Jhh24miss'),'dd-mon-yyyy hh24:mi:ss') run_end,
4 (to_date(run_end,'Jhh24miss')
5 - to_date(
6 substr(root_start,
7 2,
8 decode(instr(root_start,'/',1,2),
9 0,
10 length(root_start)+1,
11 instr(root_start,'/',1,2)
12 )-2
13 )
14 ,'Jhh24miss')
15 ) "Time difference"
16 from (
17 select name script_name, lpad(' ',2*level,' ')||job_id job
18 ,to_char(run_start,'Jhh24miss') run_start, to_char(run_end,'Jhh24miss') run_end,
19 sys_connect_by_path(to_char(run_start,'Jhh24miss'),'/') root_start
20 from jcs_jobs
21 where name = 'NORMAL_DAY'
22 connect by prior job_id = parent_job_id
23 start with PARENT_JOB_ID IS NULL and job_id = 2253800
24 );
SCRIPT_NAM JOB RUN_START RUN_END Time difference
NORMAL_DAY 2253800 23-jan-2010 15:30:16 27-jan-2010 01:06:16 3,4
NORMAL_DAY 2253801 27-jan-2010 01:06:16 28-jan-2010 15:30:16 5Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/23/la-forza-del-foglio-di-calcolo-in-una-query-la-clausola-model/] -
Start with Connect by: Showing the whole hierarchy even if child parameter
11g
Hi There,
In our case the manager_id i= employee_id for the top level manager. So when I run the sql, it eliminates the top level manager and shows the output for the next level onwards.
For the regular start with connect by option on the employee table the query used is
select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
level,
First_name as title,
NULL as icon,
EMPloyee_id as value,
First_name as tooltip,
NULL as link
from EMPLOYEES
start with Manager_id is null
connect by prior EMPLOYEE_ID = Manager_id
order siblings by First_namenow this will show the hierarchy and level starting with managers. Now if we provide the "start with Manager_id = 171" then since 171 is not a manager no rows are returned. So for this we can use something like
start with manager_id =171 or employee_id = 171However, the output would be only the employee record since 171 is the last child.
The requirement we had was that, Irrespective of the value entered, whether ultimate parent or ultimate child the output should still show the top down hierarchy. starting with that persons ultimate manager.
So for example if there are two employees, 170 and 171 and 170 is the manager of 171
If in this query I use Start with manager = 170. It will show me the manager and the child records.
However, if I use start with manager = 171 or employee_id = 171 then it will only show me only the child record. I want it to show me both the manager and employee records. i.e all the levels
I hope that make sense!
Thanks,
Ryan
Edited by: ryansun on Dec 12, 2012 1:13 AM
Edited by: ryansun on Dec 13, 2012 1:59 AMHi Alberto,
I was using this query and the output is correct. Except for one thing, the nature of our data is such that the top most manager in this case has "Manager_Id" as null so we can use "start with Manager is null"
But in our case the manager id for the top most manager is the same as his employee id.
So If I modify the query, it then does not show the "top most managers record"
WITH entire_tree AS
SELECT *
FROM employees
START WITH manager_id = 171
CONNECT BY PRIOR employee_id = manager_id
UNION
SELECT *
FROM employees
START WITH employee_id = 171
CONNECT BY employee_id = PRIOR manager_id
SELECT CASE WHEN CONNECT_BY_ISLEAF = 1 THEN 0 WHEN LEVEL = 1 THEN 1 ELSE -1 END AS status
, LEVEL
, first_name AS title
, NULL AS icon
, employee_id AS VALUE
, first_name AS tooltip
, NULL AS link
FROM entire_tree
START WITH manager_id = 100
CONNECT BY PRIOR employee_id = manager_id
ORDER SIBLINGS BY first_name;the only change I made is from
Start with manager_id is null
to
start with manager_id = 100Basically, in this case the manager_id of the top most manager is the same as his employee id. So how can we have that condition incorporated instead of checking for null.
Thanks,
Ryan -
DB is 11gR1
I have a table that defines formulas for items that are created (line_type = 1) and what ingredients are needed to make it (line_type = -1). Some ingredients also need to be made, so they will have another record in the table (different formula) with a line_type of 1, and the ingredients that make it up. Those ingredients could also be created, and so on.
So in the example below formula 807 creates item 4112949142. The line_type = -1 for formula 807 define the ingredients that make up that item. One of the ingredients, KT00518, is also a manufactured item, defined by that item with line_type = 1 which is formula 1420. Ingredient WP50255 is manufactured with formula 3030.
What I need to be able to do, is starting with formula 807, recursively loop through all the formulas to get all of the ingredients needed to make that item:
KT00518
PK15199
PK13947
RM31009
RM30711
RM31004
WP50255
RM30951
RM30948
RM30981
RM30957
In this simple case it would be easy because there are no formulas that are not related to this item, but obviously I need a way to do this with a start with/connect by in the real world:
SELECT *
FROM XX_FORMULA
WHERE line_type = -1
DROP TABLE XX_FORMULA;
CREATE TABLE XX_FORMULA
FORMULA_ID NUMBER NOT NULL,
ITEM VARCHAR2(60) NOT NULL,
LINE_TYPE NUMBER NOT NULL,
LINE_NO NUMBER NOT NULL
--Top Level
INSERT INTO XX_FORMULA
VALUES( 807,'4112949142',1, 1);
INSERT INTO XX_FORMULA
VALUES( 807,'KT00518',-1, 1);
INSERT INTO XX_FORMULA
VALUES( 807,'PK15199',-1, 2);
INSERT INTO XX_FORMULA
VALUES( 807,'PK13947',-1, 3);
--Middle
INSERT INTO XX_FORMULA
VALUES( 1420,'KT00518',1, 1);
INSERT INTO XX_FORMULA
VALUES( 1420,'RM31009',-1, 1);
INSERT INTO XX_FORMULA
VALUES( 1420,'RM30711',-1, 2);
INSERT INTO XX_FORMULA
VALUES( 1420,'RM31004',-1, 3);
INSERT INTO XX_FORMULA
VALUES( 1420,'WP50255',-1, 4);
--Leaf
INSERT INTO XX_FORMULA
VALUES( 3030,'WP50255',1, 1);
INSERT INTO XX_FORMULA
VALUES( 3030,'RM30951',-1, 1);
INSERT INTO XX_FORMULA
VALUES( 3030,'RM30948',-1, 2);
INSERT INTO XX_FORMULA
VALUES( 3030,'RM30981',-1, 3);
INSERT INTO XX_FORMULA
VALUES( 3030,'RM30957',-1, 4);Thanks in advance for your help.
--JohnnieHi,
Vortex13 wrote:
DB is 11gR1
I have a table that defines formulas for items that are created (line_type = 1) and what ingredients are needed to make it (line_type = -1). Some ingredients also need to be made, so they will have another record in the table (different formula) with a line_type of 1, and the ingredients that make it up. Those ingredients could also be created, and so on.
So in the example below formula 807 creates item 4112949142. The line_type = -1 for formula 807 define the ingredients that make up that item. One of the ingredients, KT00518, is also a manufactured item, defined by that item with line_type = 1 which is formula 1420. Ingredient WP50255 is manufactured with formula 3030.Okay, so that explains that
VALUES( 807,'KT00518',-1, 1);is the parent of
VALUES( 1420,'KT00518',1, 1);But it looks like there's also another kind of parent-child relationship in this table. That is, the last row I showed above apparantly has children. I'm guessing that
VALUES( 1420,'RM31009',-1, 1);is one of its children. That is, a row with line_type=1 can have children: any row with the same formula_id and line_type=-1 is its child. Is that right?
If so:
SELECT *
FROM xx_formula
WHERE line_type = -1
START WITH formula_id IN (807) -- Change as needed
AND line_no = 1
CONNECT BY ( item = PRIOR item
AND line_type = 1
AND PRIOR line_type = -1
OR ( formula_id = PRIOR formula_id
AND line_no = PRIOR line_no + 1
What I need to be able to do, is starting with formula 807, recursively loop through all the formulas to get all of the ingredients needed to make that item:
KT00518
PK15199
PK13947
RM31009
RM30711
RM31004
WP50255
RM30951
RM30948
RM30981
RM30957I get 20 rows of output, not just the 11 you want. I guess I don't understand the requirements.
Here are my results:
FORMULA_ID ITEM LINE_TYPE LINE_NO
807 KT00518 -1 1
1420 RM31009 -1 1
1420 RM30711 -1 2
1420 RM31004 -1 3
1420 WP50255 -1 4
3030 RM30951 -1 1
3030 RM30948 -1 2
3030 RM30981 -1 3
3030 RM30957 -1 4
807 PK15199 -1 2
807 PK13947 -1 3
807 KT00518 -1 1
1420 RM31009 -1 1
1420 RM30711 -1 2
1420 RM31004 -1 3
1420 WP50255 -1 4
3030 RM30951 -1 1
3030 RM30948 -1 2
3030 RM30981 -1 3
3030 RM30957 -1 4Take a couple of examples where I'm getting the wrong results, and explain again, using different words, how you get the right results in those places.
Maybe I just need to say SELECT DISTINCT .
In this simple case it would be easy because there are no formulas that are not related to this item, Yes, it would be better to add a couple of rows that are not related. Why don't you?
but obviously I need a way to do this with a start with/connect by in the real world:Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful. -
Start with Connect By: What if Parent is the Child?
Version : 11g
Hi There,
I had a question regarding Start with Connect by.
The following is an example from the ORacle help from the Emploees table
select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
level,
First_name as title,
NULL as icon,
EMPloyee_id as value,
First_name as tooltip,
NULL as link
from EMPLOYEES
start with Manager_id ='171'
connect by prior EMPLOYEE_ID = Manager_id
order siblings by First_nameNow this works fine and shows the levels. In the help the start with is actually
start with Manager_id is nullNow if we use a lowest level employee using something like
start with Manager_id = '171'no rows are returned. This is because there are no child records for this employee (he is not a manager).
However, is it possible to atleast show this one record as the output? Any suggestions?
Thanks,
Ryan
Edited by: ryansun on Dec 10, 2012 10:51 PMOne way
start with
( manager_id ='171'
or
employee_id='171'
and '171' not in (
select distinct manager_id
from employees
where manager_id is not null
)Edited by: jeneesh on Dec 11, 2012 12:35 PM -
Every time I try to play Amazon video on iPad, it shows "our Internet connection is currently using an HTTP proxy, content playbacks not supported when a proxy is configured". Though I can play it on iPhone which has same Internet connection.
Can any one please help?This helped me
http://mashtips.com/amazon-instant-video-http-proxy-error-on-ipad/ -
SQL with connect by prior running for a long time
Hi,
We are using Oracle 10g. Below is a cursor sql which is having performance issues. The pAccountid is being passed from the output of a different cursor. But this cursor sql is running for a long time. Could you please help me in tuning this sql. I believe the subquery with connect by prior is causing the trouble.
The TRXNS is a huge table which is not partitioned. The query is forced to use the index on the accountid of the TRXNS table.
The accountlink table has 20,000 records and the TRXNStrack table has 10,000 records in total.
This sql executes for 200,000 pAccountids and runs for more than 8 hours.
SELECT /*+ INDEX(T TRXNS_ACCOUNTID_NIDX) */ AL.FROMACCOUNTID oldaccountid ,
A.ACCOUNTNUM oldaccountnum,
T.TRXNSID,
T.TRXNSTYPEID,
T.DESCRIPTION ,
T.postdt,
T.TRXNSAMT
FROM
ACCOUNTLINK AL,
TRXNS T,
ACCOUNT A
WHERE AL.TOACCOUNTID IN
(SELECT TOACCOUNTID FROM ACCOUNTLINK START WITH TOACCOUNTID = pAccountid
CONNECT BY PRIOR FROMACCOUNTID = TOACCOUNTID)
AND AL.FROMACCOUNTID = T.ACCOUNTID
AND A.ACCOUNTID = AL.FROMACCOUNTID
AND NOT EXISTS (select 1 from TRXNStrack trck where trck.TRXNSid = t.TRXNSid AND TRXNSTrackReasonid = 1)
AND T.postdt > A.CLOSEDATE
AND T.postdt >= sysdate-2
AND T.postdt <= sysdate;
Create script for trxn table:
CREATE TABLE SP.TRXNS
TRXNSID NUMBER(15) CONSTRAINT "BIN$rpIQEeyLDfbgRAAUT4DEnQ==$0" NOT NULL,
ACCOUNTID NUMBER(15) CONSTRAINT "BIN$rpIQEeyMDfbgRAAUT4DEnQ==$0" NOT NULL,
STATEMENTID NUMBER(15),
TRXNSTYPEID NUMBER(15),
DESCRIPTION VARCHAR2(80 BYTE),
postdt DATE,
TRXNSAMT NUMBER(12,2),
TRXNSREQID NUMBER(15),
LASTUPDATE DATE,
SOURCEID NUMBER(15),
HIDE VARCHAR2(1 BYTE)
TABLESPACE SO_TRXN_DATA
RESULT_CACHE (MODE DEFAULT)
PCTUSED 40
PCTFREE 10
INITRXNS 2
MAXTRXNS 255
STORAGE (
INITIAL 50M
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
FREELISTS 8
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE INDEX SP.TRXNS_ACCOUNTID_NIDX ON SP.TRXNS
(ACCOUNTID, postdt)
LOGGING
TABLESPACE SO_TRXN_INDEX
PCTFREE 10
INITRXNS 2
MAXTRXNS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
NOPARALLEL;
below is the executing plan for this sql taken from toad :
PLAN_ID
TIMESTAMP
OPERATION
OPTIONS
OBJECT_OWNER
OBJECT_NAME
OBJECT_ALIAS
OBJECT_INSTANCE
OBJECT_TYPE
OPTIMIZER
SEARCH_COLUMNS
ID
PARENT_ID
DEPTH
POSITION
COST
CARDINALITY
BYTES
CPU_COST
IO_COST
TEMP_SPACE
ACCESS_PREDICATES
FILTER_PREDICATES
PROJECTION
TIME
QBLOCK_NAME
1121
9/10/2013 3:30
FILTER
1
0
1
1
NOT EXISTS (SELECT 0 FROM "TRXNSTRACK" "TRCK" WHERE "TRXNSTRACKREASONID"=1 AND "TRCK"."TRXNSID"=:B1)
AL."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
SEL$5DA710D3
1121
9/10/2013 3:30
FILTER
2
1
2
1
SYSDATE@!-2<=SYSDATE@!
AL."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
1121
9/10/2013 3:30
NESTED LOOPS
3
2
3
1
(#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
1121
9/10/2013 3:30
NESTED LOOPS
4
3
4
1
5
1
119
3989858
4
(#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A".ROWID[ROWID,10]
1
1121
9/10/2013 3:30
NESTED LOOPS
5
4
5
1
4
1
90
3989690
3
(#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22]
1
1121
9/10/2013 3:30
HASH JOIN
SEMI
6
5
6
1
3
2
54
3989094
2
AL."TOACCOUNTID"="TOACCOUNTID"
(#keys=1) "AL"."FROMACCOUNTID"[NUMBER,22]
1
1121
9/10/2013 3:30
INDEX
FULL SCAN
SP
ACCOUNTLINK_AK1
AL@SEL$1
INDEX (UNIQUE)
ANALYZED
7
6
7
1
1
18
252
107
1
AL."FROMACCOUNTID"[NUMBER,22], "AL"."TOACCOUNTID"[NUMBER,22]
1
SEL$5DA710D3
1121
9/10/2013 3:30
VIEW
SYS
VW_NSO_1
VW_NSO_1@SEL$5DA710D3
11
VIEW
8
6
7
2
2
18
234
107
1
TOACCOUNTID[NUMBER,22]
1
SEL$683B0107
1121
9/10/2013 3:30
CONNECT BY
NO FILTERING WITH START-WITH
9
8
8
1
TOACCOUNTID=PRIOR "FROMACCOUNTID"
TOACCOUNTID=56354162
TOACCOUNTID[NUMBER,22], "FROMACCOUNTID"[NUMBER,22], PRIOR NULL[22], LEVEL[4]
SEL$683B0107
1121
9/10/2013 3:30
INDEX
FULL SCAN
SP
ACCOUNTLINK_AK1
ACCOUNTLINK@SEL$3
INDEX (UNIQUE)
ANALYZED
10
9
9
1
1
18
252
107
1
ACCOUNTLINK.ROWID[ROWID,10], "FROMACCOUNTID"[NUMBER,22], "TOACCOUNTID"[NUMBER,22]
1
SEL$3
1121
9/10/2013 3:30
TABLE ACCESS
BY INDEX ROWID
SP
TRXNS
T@SEL$1
2
TABLE
ANALYZED
11
5
6
2
1
1
63
298
1
T."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22]
1
SEL$5DA710D3
1121
9/10/2013 3:30
INDEX
RANGE SCAN
SP
TRXNS_ACCOUNTID_NIDX
T@SEL$1
INDEX
ANALYZED
2
12
11
7
1
1
1
224
1
AL."FROMACCOUNTID"="T"."ACCOUNTID" AND "T"."POSTDT">=SYSDATE@!-2 AND "T"."POSTDT"<=SYSDATE@!
T.ROWID[ROWID,10], "T"."POSTDT"[DATE,7]
1
SEL$5DA710D3
1121
9/10/2013 3:30
INDEX
UNIQUE SCAN
SP
ACCOUNT_PK
A@SEL$1
INDEX (UNIQUE)
ANALYZED
1
13
4
5
2
1
1
90
1
A."ACCOUNTID"="AL"."FROMACCOUNTID"
A.ROWID[ROWID,10]
1
SEL$5DA710D3
1121
9/10/2013 3:30
TABLE ACCESS
BY INDEX ROWID
SP
ACCOUNT
A@SEL$1
3
TABLE
ANALYZED
14
3
4
2
1
1
29
168
1
A."CLOSEDATE"<SYSDATE@! AND "T"."POSTDT">"A"."CLOSEDATE"
A."ACCOUNTNUM"[VARCHAR2,19]
1
SEL$5DA710D3
1121
9/10/2013 3:30
INDEX
RANGE SCAN
SP
TRXNSTRACK_TRXNSID_NIDX
TRCK@SEL$6
INDEX
ANALYZED
2
15
1
2
2
1
1
10
73
1
TRCK."TRXNSID"=:B1 AND "TRXNSTRACKREASONID"=1
TRCK."TRXNSID"[NUMBER,22], "TRXNSTRACKREASONID"[NUMBER,22]
1
SEL$6
Please help me in debugging this thanks!Hi,
Thanks for your thought on this subject. Below is the trace info that I got from the DBA
SQL ID: d0x879qx2zgtz Plan Hash: 4036333519
SELECT /*+ INDEX(T TRXNS_ACCOUNTID_NIDX) */ AL.FROMACCOUNTID OLDACCOUNTID ,
A.ACCOUNTNUM OLDACCOUNTNUM, T.TRXNSID, T.TRXNSTYPEID, T.DESCRIPTION ,
T.POSTDT, T.TRXNSAMT
FROM
ACCOUNTLINK AL, TRXNS T, ACCOUNT A WHERE AL.TOACCOUNTID IN (SELECT
TOACCOUNTID FROM ACCOUNTLINK START WITH TOACCOUNTID = :B3 CONNECT BY PRIOR
FROMACCOUNTID = TOACCOUNTID) AND AL.FROMACCOUNTID = T.ACCOUNTID AND
A.ACCOUNTID = AL.FROMACCOUNTID AND NOT EXISTS (SELECT 1 FROM TRXNSTRACK
TRCK WHERE TRCK.TRXNSID = T.TRXNSID AND TRXNSTRACKREASONID = :B4 ) AND
T.POSTDT > A.CLOSEDATE AND T.POSTDT >= :B2 AND T.POSTDT <= :B1
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 17160 2.10 1.87 0 0 0 0
Fetch 17160 7354.61 7390.86 169408 5569856 883366791 0
total 34320 7356.71 7392.74 169408 5569856 883366791 0
Misses in library cache during parse: 0
Optimizer mode: CHOOSE
Parsing user id: 38 (recursive depth: 1)
SQL ID: gs89hpavb4cts Plan Hash: 3415795327
SELECT A.ACCOUNTID, C.MEMBERID, A.PROGRAMID, A.ACCOUNTNUM
FROM
CUSTOMER C, CUSTOMERACCOUNT CA, ACCOUNT A, PROGRAMPARAMVALUE PPV,
BATCHPROCESSPROGRAM BP WHERE A.PROGRAMID = BP.PROGRAMID AND A.PROGRAMID =
PPV.PROGRAMID AND A.ACCOUNTID = CA.ACCOUNTID AND CA.PERSONID = C.PERSONID
AND PPV.PARAMID = :B2 AND PPV.VALUE = 'Y' AND BP.PROCESSID = :B1 AND BP.RUN
= 'Y' AND A.ACCOUNTTYPEID = 4 AND A.ACCOUNTSTATUSID = 1 AND C.MEMBERID IS
NOT NULL
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 172 13.14 115.34 80826 278650 0 17200
total 172 13.14 115.34 80826 278650 0 17200
Misses in library cache during parse: 0
Parsing user id: 38 (recursive depth: 1)
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 17160 2.10 1.87 0 0 0 0
Fetch 17332 7367.75 7506.21 250234 5848506 883366791 17200
total 34492 7369.85 7508.09 250234 5848506 883366791 17200
Misses in library cache during parse: 0
2 user SQL statements in session.
0 internal SQL statements in session.
2 SQL statements in session.
Trace file: svoprod_ora_12346.trc
Trace file compatibility: 11.1.0.7
Sort options: default
1 session in tracefile.
2 user SQL statements in trace file.
0 internal SQL statements in trace file.
2 SQL statements in trace file.
2 unique SQL statements in trace file.
66499 lines in trace file.
7516 elapsed seconds in trace file. -
How to pass multiple parameters to Query using START WITH, CONNECT BY OBIEE
Hi
I have following oracle query which need to be used as a Data Source in OBIEE Physical Layer. I guess I have to create stored proc. How do I implement this in OBIEE RPD and how do I implement the respective Dashboard prompts for the parameters.
SELECT
CIRC.PATH_NAME, CIRC.BANDWIDTH , CIRC.CATEGORY, CIRC.CUSTOMER_ID,
CIRC.STATUS, CIRC.CUSTOMER_NAME,
QUER.LEV
FROM
CIRCUIT_PATH circ, VAL_CUSTOMER cust,
( SELECT
DISTINCT CIRC_PATH_INST_ID, LEVEL LEV
FROM
CIRC_PATH_ELEMENT
START WITH
CIRC_PATH_ELEMENT.CIRC_PATH_INST_ID IN ( SELECT
DISTINCT CIRC_PATH_INST_ID
FROM
PORTS a
WHERE SITE_NAME = @variable('Enter a Site Name')
AND CARD_SLOT = @variable('Enter a Card Slot')
CONNECT BY
PRIOR CIRC_PATH_ELEMENT.CIRC_PATH_INST_ID =
CIRC_PATH_ELEMENT.PATH_INST_ID
AND ELEMENT_TYPE != 'K' ) QUER
WHERE
circ.circ_path_inst_id = QUER.CIRC_PATH_INST_ID
and circ.cust_inst_id = cust.cust_inst_id (+)
ORDER BY
LEV DESC , CIRC.PATH_NAME ASC, CIRC.BANDWIDTH ASC
Thanks
DGHi John
Thanks. I looked at your URL. I do have package. Just using procedure. So my initialization string (For stored proc in Physical Layer of RPD) is
exec demo.add_employee(VALUEOF(NQ_SESSION.empid1));
But when I run request in Answer I get the error
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 900, message: ORA-00900: invalid SQL statement at OCI call OCIStmtExecute: exec demo.add_employee(105); . [nQSError: 17011] SQL statement execution failed. (HY000)
What should I put in initialization string in RPD?
Thanks
DG -
Hierarchy/heirarchical queries/query start with connect
ok... I have seen many examples of using hierachical queries. All of the example has parent as null and children with 1 parent. I haven't seen any query that queries a child with multiple parents.
For example.
Table A:
Child--Parent
1--null
2--1
3--1
3--2
4--3
5--2
Select query:
Select child, level
from A
start with child = 3
connect by prior child = parent
Result
Child--Level
3--1
4--2
3--1
4--2
Notice that it display the child '3' twice. Its because it has 2 different parent.
My question is that, how do I make the query to display this iteration once?Hi, Sentinel,
I'd love to see a solution that simple, but I don't think it's possible.
Suppose you want to see child=2 and all it's descendants:
--<"begin sample data">
with a as (select 1 child, null parent from dual
union all select 2, 1 from dual
union all select 3, 1 from dual
union all select 3, 2 from dual
union all select 4, 3 from dual
union all select 5, 2 from dual
--<"cut here">
Select child, level
from (select child, min(parent) parent from a group by child)
start with child = 2
connect by prior child = parent;Produces this output:
CHILD LEVEL
2 1
5 2I believe OP wants to get this for the descendants of child=2:
CHILD LEVEL
2 1
5 2[b]
3 2
4 3So what happened to child=3? For child=3, MIN (parent) = 1, according to this query. That's true when the universe is the entire table, but we're only interested in child=2 and its descendants.
Message was edited by:
Frank Kulash
By the way, the comments
--<"begin sample data">
and
--<"cut here">
are brilliant! -
How to call a Query from widget which has mandatory variables/filter values
Dear Gurus,
I want to show data from BI query (BEX) in Wedget, which has variable/ Filter as input parameter. Please tell me how add these parameters while calling query throgh web service.
Regards,
Aslam KhanHi Aslam,
Kindly refer to Page Number 49 u2013 23rd Point and Page 50 and 51 in the SAPEnterpriseWidgetDevelopmentGuide.pdf u2013 Which explains how to pass the Import / input Parameters.
You can also refer these links u2013 [How to pass more than one value in RfcRequest ?;
[how to bind an input field with an rfc input;
Hope it helpsu2026
Regards,
Shilpa B.V -
How to form an Endeca query where a field must start with certain letters
hi, Is it possible to form an Endeca query to retrieve a field that must start with certain letters? Say like get all users who's first letter is 'A' ? I checked with Range filters but it is supporting only numerical fields as well as Wild card search. But nothing worked well so far. any suggestion?
Yes. Here's the gist of how it works:
Typeahead is commonly implemented by enabling wildcard search on one or more Dimensions. An AJAX query is sent out containing the beginning of a search term. A controller in the app layer answers that AJAX query and formulates an Endeca Dimension Search query. It sends that off to the Endeca MDEX engine. Endeca responds with relevant Dimension matches. The controller returns these to the client who made the AJAX request. They are rendered as hyperlinks that lead to a particular navigation state in the catalog. -
Query string field based on "starts with"
Is it possible to query a cache with a filter that does a "starts with" for a particular field or key?
For example, if I want all objects that have a field/key that start with "do", it will return objects that have
"do"
"dog"
"doggy"
etc...
thanx
KevinHi Kevin,
You can use LikeFilter for your case.
To query against a field,
new LikeFilter("FIELD_NAME", "start with%")To query against key,
new LikeFilter(new KeyExtractor(), "start with%", "\\", false)You can refer the Java API document http://download.oracle.com/docs/cd/E15357_01/coh.360/e15725/com/tangosol/util/filter/LikeFilter.html.
Regards,
Rock
Oracle ACS -
How to perform order by in START with connect by ?
I am using the start with function to call range of bom code. Here is the code :
SELECT level BOM_LEVEL, BCODE, bi_item_code,bi_qty
FROM OM_BOM, OM_BOM_ITEM_DETAIL, OM_ITEM_PLANT_PROPERTY_HEAD,
OM_ITEM_PLANT_PROPERTY_DETAIL, OM_ITEM
WHERE BOM_CODE = BI_BOM_CODE
AND IPH_SYS_ID = IPD_IPH_SYS_ID
AND IPH_PLANT_CODE = IPD_IPH_PLANT_CODE
AND IPH_ITEM_CODE = IPD_IPH_ITEM_CODE
AND IPH_GRADE_CODE_1 = IPD_IPH_GRADE_CODE_1
AND IPH_GRADE_CODE_2 = IPD_IPH_GRADE_CODE_2
AND IPH_ITEM_CODE = ITEM_CODE
AND NVL(ITEM_FRZ_FLAG_NUM,2) = 2
AND IPH_APP_CODE_NUM = 1
AND BOM_ITEM_CODE = IPH_ITEM_CODE
AND BOM_CODE = BI_BOM_CODE
AND NVL(BOM_DEVELOPMENT_YN_NUM, 2) = 2 commented by vellingiri.n on 22/06/2007 for enabling the development BOM
AND NVL(BOM_FRZ_FLAG_NUM, 2) = 2
AND IPD_ATTR_CODE = 'DFLT_BOM_CODE'
AND IPD_ATTR_VALUE IS NOT NULL
AND BOM_CODE = IPD_ATTR_VALUE
CONNECT BY PRIOR BI_ITEM_CODE = BOM_ITEM_CODE
AND PRIOR BI_LOWEST_LEVEL_YN = 'N'
--START WITH BOM_CODE = :PWH_BOM_CODE
START WITH ( BOM_CODE >= :F_BOM AND BOM_CODE <= :T_BOM )
The range is from bom code : 95-01-001 to 95-01-002
And the output is :-
Bom Level____bom_code____Bom_item_code_________bi_qty
1____________95-01-001____95-01-001______________1
1____________95-01-001____50-23-008______________2
1____________95-01-001____50-37-001______________1
2____________50-37-001____59-01-001______________2
2____________50-37-001____4230112_______________2
3____________59-01-001____132133________________4
2____________50-23-008____232323________________5
2____________50-23-008____12-11-22_______________3
1____________95-01-002____232323________________5
2____________95-01-002____232311________________1
........ and more
My problem right now, I want to group the bom so that I will be know the total qty of each bom from the range of bom that I count. That output was shown when I run the query in sql. But when I put into report 6i, the grouping has caused the arrangement of my bom runing up and down. How can I control the bom or any group funtion that I can used so that it will group the bom before start with a new bom ???
please help me. Thanks.
LimYou wrote that the output in SQL*Plus is correct but not in Oracle Reports 6i.
Seems to me you have a Reports issue and should ask in that forum. -
Help needed with CONNECT BY PRIOR
I need to display salesrep-manager hierarchy. I'm using the following SQL and am sure I'm doing something wrong somewhere, but just can't pinpoint. Any help is greatly appreciated.
<pre>
SELECT sf.source_name salesrep
,mgr.full_name manager
,level
FROM as_salesforce_v sf
,per_all_assignments_f pass
,per_all_people_f mgr
WHERE sf.role_name = 'Sales Representative'
AND SYSDATE BETWEEN nvl(sf.start_date_active, SYSDATE) AND
nvl(sf.end_date_active, SYSDATE)
AND SYSDATE BETWEEN nvl(pass.effective_start_date, SYSDATE) AND
nvl(pass.effective_end_date, SYSDATE)
AND SYSDATE BETWEEN nvl(mgr.effective_start_date, SYSDATE) AND
nvl(mgr.effective_end_date, SYSDATE)
CONNECT BY PRIOR mgr.person_id = pass.supervisor_id
START WITH pass.person_id = sf.employee_person_id;
</pre>
TIA
Alka.
Forgot to mention, the SQL takes forever to run.
Message was edited by:
user498444as_salesforce_v view stores the salesrep name (as specified by the condition sf.role_name = 'Sales Representative'). This view also has rows for managers of salesreps as that's how Oracle Sales app allows the users to access the app. This table stores employee id in column employee_person_id.
per_all_assignments_f table stores the assignments for all the employees (including salesreps and that's why condition START WITH pass.person_id = sf.employee_person_id). It also stores the employee id for the manager (column supervisor_id).
per_all_people_f has all the employee records (including manager records) and the column person_id is the employee id (condition pass.supervisor_id = mgr.person_id).
Hope this explanation is helpful.
Maybe you are looking for
-
when tryin to load SDM or a router i get this error "RPC is denied thought the connected interface update cannot proceed" this is after the correcte authentication to the devices and selecting the SDM(or SDM express) to be loaded when tryin to use th
-
Home automation - integrate creston with apple
I implemented home automation with creston system. I'd like to improve the network using time capsule, airport express for new pair of speakers and apple tv to share contents. any experience from somebody?
-
Help with histogram related query
Hi there, I'm trying to collect data through a query to draw an histogram. Its between lag count and user count. Here's my query, select (Y.lag_range /10) * 10 as range_start, (((Y.lag_range/10) + 1) * 10) -1 as range_end, sum(Y.user_count) as user_c
-
Get component closest to point x, y
Here is a fun one... I have a JPanel with various Components in it that are layed out manually (ie.. null layout). When the user clicks in this JPanel I would like to know which of these Components is closest to the point where the user clicked. Does
-
Oracle 8i download for windows 98
I cannot access the file to download this program. I get as far as clicking on the option for the zipfile but never get the dowload box - instead I get a DNS Detect Network Settings error on my AT&T Brodband Internet ISP, and a connection hang-up err