Performance issue Bulk Insert PL/SQL table type
Hi allI put in work of a batch to fill a table with a large number of data records(>3,000,000). To reduce the execution time, I used PL/SQL tables to temporarily store data that must be written to the destination table. Once all documents are piling up in the PL/SQL table I use a FORALL operator for bulk insert the records in the physical table.
Currently, I follow two approaches to implement the process described above. (Please see the code segments below). I need to choose how to best wise performance between these two approaches. I really appreciate all the comments of experts about the runtime of the two approaches.
(I don't see much difference in consumption of time in my test environment that has limited the data series. This process involves building a complex set of structures of large product once deployed in the production environment).
Approach I:_
DECLARE
TYPE of test_type IS test_tab % ROWTYPE directory INDEX TABLE;
test_type_ test_type.
ins_idx_ NUMBER;
BEGIN
ins_idx_: = 1;
NESTED LOOPS
test_type_ (ins_idx_) .column1: = value1;
test_type_ (ins_idx_) .column2: = value2;
test_type_ (ins_idx_) .column3: = value3;
ins_idx_: = ins_idx_ + 1;
END LOOP;
I_ FORALL in 1.test_type_. COUNTY
INSERT INTO test_tab VALUES (i_) test_type_;
END;
/
Approach II:_
DECLARE
Column1 IS a TABLE OF TYPE test_tab.column1%TYPE INDEX DIRECTORY.
Column2 IS a TABLE OF TYPE test_tab.column2%TYPE INDEX DIRECTORY.
Column3 IS a TABLE OF TYPE test_tab.column3%TYPE INDEX DIRECTORY.
column1 column1_;
column2_ Column2;
column3_ Column3;
ins_idx_ NUMBER;
BEGIN
ins_idx_: = 1;
NESTED LOOPS
column1_ (ins_idx_): = value1;
column2_ (ins_idx_): = value2;
column3_ (ins_idx_): = value3;
ins_idx_: = ins_idx_ + 1;
END LOOP;
FORALL idx_ in 1.column1_. COUNTY
INSERT
IN n_part_cost_bucket_tab)
Column1,
Column2,
Column3)
VALUES)
column1_ (idx_),
column2_ (idx_),
column3_ (idx_));
END;
/
Best regards
Lorenzo
Published by: nipuna86 on January 3, 2013 22:23
nipuna86 wrote:
I put in work of a batch to fill a table with a large number of data records(>3,000,000). To reduce the execution time, I used PL/SQL tables to temporarily store data that must be written to the destination table. Once all documents are piling up in the PL/SQL table I use a FORALL operator for bulk insert the records in the physical table.
Performance is more than just reducing the execution time.
Just as smashing a car stops more than a car in the fastest possible time.
If it was (breaking a car stopping all simply), then a brick with reinforced concrete wall construction, would have been the perfect way to stop all types of all sorts of speed motor vehicles.
Only problem (well more than one actually) is that stop a vehicle in this way is bad for the car, the engine, the driver, passengers and any other content inside.
And pushing 3 million records in a PL/SQL 'table' (btw, that is a WRONG terminology - there no PL/SQL table structure) in order to run a SQL cursor INSERT 3 million times, to reduce the execution times, is no different than using a brick wall to stop a car.
Both approaches are pretty well imperfect. Both places an unreasonable demand on the memory of the PGA. Both are still row-by-row (aka slow-by-slow) treatment.
Tags: Database
Similar Questions
-
pl/sql table type issue (basic)
Hello..
I am new to pl/sql collections...
And I tried the following, but how do I view the output using the dbms_output
Thank youSQL> declare 2 type emptype is table of emp%rowtype index by pls_integer; 3 etab emptype; 4 begin 5 select * into etab(100) from emp where empno=7566; 6 dbms_output.put_line(etab.sal); 7 end; 8 / dbms_output.put_line(etab.sal); * ERROR at line 6: ORA-06550: line 6, column 28: PLS-00302: component 'SAL' must be declared ORA-06550: line 6, column 2: PL/SQL: Statement ignored
Published by: josh1612 on March 24, 2009 23:50Try
... dbms_output.put_line(etab(100).sal); ...
-
performance issue with the Oracle SQL query
Dears
Good evening
I am new to begin to use Oracle SQL, I have a sql query which takes longer to run in production.
Each table in the query contains 1.2 million records and DBA suggested using the "Oracle - tips. I don't have good knowledge on this subject and the difficulties to implement this advice for imrpovise performance. In the product the jobs Informatica are failed and stuck with this problem of query performance.
I ask this forum for an emergency for me to solve this problem by using "advice". kindly help me.
SELECT
CASE.ID,
CASE. DTYPE,
CASE. Version
CASE. EXTERNAL_REF,
CASE. CREATION_TS,
RQ. TYPE
Of
PAS_CASE CASE,
AS_REQUEST RQ,
CN PAS_CONTEXT
where rq.case_id = case.id
AND rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.)
and CN. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
AND CAST (CN. CREATION_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
AND
CAST (CN. CREATION_TS AS DATE) < TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)-2nd request
SELECT
RA.ID,
RHEUMATOID ARTHRITIS. Version
RHEUMATOID ARTHRITIS. REQUEST_ID,
RA.NAME,
RHEUMATOID ARTHRITIS. VALUE,
RHEUMATOID ARTHRITIS. LOB_ID,
RHEUMATOID ARTHRITIS. DTYPE,
RHEUMATOID ARTHRITIS. CREATION_TS,
TASK. MAIN_REQ_TYPE
PAS_REQUESTATTRIBUTE RA
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
) task
on the RA REQUEST_ID = task.ID
and RA.ID between $$ LOW_ID1 AND $$ HIGH_ID1
UNIONSELECT
RA.ID,
RHEUMATOID ARTHRITIS. Version
RHEUMATOID ARTHRITIS. REQUEST_ID,
RA.NAME,
RHEUMATOID ARTHRITIS. VALUE,
RHEUMATOID ARTHRITIS. LOB_ID,
RHEUMATOID ARTHRITIS. DTYPE,
RHEUMATOID ARTHRITIS. CREATION_TS,
MAIN_REQ. TYPE
PAS_REQUESTATTRIBUTE RA
Join
(
Select rq.id, rq.type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
on the RA REQUEST_ID = main_req.ID-3rd request
SELECT
RB.ID,
RB. DTYPE,
RB. Version
RB. TYPE,
RB. CREATION_TS,
RB. TASK_ID,
RB. Color
RB. GLOBAL_RESULT,
TASK. MAIN_REQ_TYPE
Of
PAS_RESULTBLOCK RB
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
) task
We rb.task_id = task.ID
and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1
and RB. TYPE is not null
and RB. TYPE IN
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
UNION
SELECT
RB.ID,
RB. DTYPE,
RB. Version
RB. TYPE,
RB. CREATION_TS,
RB. TASK_ID,
RB. Color
RB. GLOBAL_RESULT,
TASK. MAIN_REQ_TYPE
Of
PAS_RESULTBLOCK RB
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
) task
We rb.task_id = task.ID
and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1
and RB. TYPE is nullSELECT
RB.ID,
RB. DTYPE,
RB. Version
RB. TYPE,
RB. CREATION_TS,
RB. TASK_ID,
RB. Color
RB. GLOBAL_RESULT,
TASK. MAIN_REQ_TYPE
Of
PAS_RESULTBLOCK RB
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
) task
We rb.task_id = task.ID
and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1
and RB. TYPE is not null
and RB. TYPE IN
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
UNION
SELECT
RB.ID,
RB. DTYPE,
RB. Version
RB. TYPE,
RB. CREATION_TS,
RB. TASK_ID,
RB. Color
RB. GLOBAL_RESULT,
TASK. MAIN_REQ_TYPE
Of
PAS_RESULTBLOCK RB
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
) task
We rb.task_id = task.ID
and rb.ID between $$ LOW_ID1 AND $$ HIGH_ID1
and RB. TYPE is null
-4th query
SELECT
RI.ID,
UII DTYPE,
UII Version
UII RESULTBLOCK_ID,
RI.NAME,
UII VALUE,
UII UNIT,
UII Color
UII LOB_ID,
UII CREATION_TS,
UII SEQUENCE,
UII DETAILLEVEL,
RES_BLK. MAIN_REQ_TYPE
Of
RI PAS_RESULTITEM
Join
(
Select
rb.ID, rb. TYPE rb_type, task. TYPE as the task_type, task. pas_resultblock rb main_req_type
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between the 20141999999999999 AND 20141800000000000
) task
We rb.task_id = task.ID
and rb.ID between the 20141999999999999 AND 20141800000000000
and RB. TYPE IN
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
) res_blk
On ri.resultblock_id = res_blk.ID
where IN RI.NAME
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and RI.ID between the 20141999999999999 AND 20141800000000000
and RI.NAME is not null
UNIONSelect
RI.ID,
UII DTYPE,
UII Version
UII RESULTBLOCK_ID,
RI.NAME,
UII VALUE,
UII UNIT,
UII Color
UII LOB_ID,
UII CREATION_TS,
UII SEQUENCE,
UII DETAILLEVEL,
RES_BLK. MAIN_REQ_TYPE
of pas_resultitem ri
Join
(
Select
rb.ID, rb. TYPE rb_type, task. TYPE as the task_type, task. pas_resultblock rb main_req_type
Join
(
Select tsk.ID, tsk. TYPE, main_req_type main_req.
of tsk PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between the 20141999999999999 AND 20141800000000000
) task
We rb.task_id = task.ID
and rb.ID between the 20141999999999999 AND 20141800000000000
) res_blk
On ri.resultblock_id = res_blk.ID
where RI.ID between 20141800000000000 20141999999999999 AND
and RI.NAME is null-REQUEST OF 5HT
SELECT
TSK.ID,
TSK. Version
TSK. DTYPE,
TSK. CASE_ID,
TSK. TYPE,
TSK. CORRELATION_ID,
TSK. INITIATOR,
TSK. EXECUTOR,
TSK. CATEGORY,
TSK. PARENT_CONTEXT_ID,
TSK. CREATION_TS,
MAIN_REQ. MAIN_REQ_TYPE
Of
TSK PAS_REQUEST
Join
(
Select cn.id as context_id, rq. TYPE main_req_type
of PAS_REQUEST rq
Cn PAS_CONTEXT
where rq.id = cn.request_id
and rq. DTYPE = "MAINREQUEST."
and rq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and rq.ID between the 20141999999999999 AND 20141800000000000
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk. DTYPE in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.ID between $$ LOW_ID1 AND $$ HIGH_ID1
UNION
Select
MREQ.ID,
MREQ. Version
MREQ. DTYPE,
MREQ. CASE_ID,
MREQ. TYPE,
MREQ. CORRELATION_ID,
MREQ. INITIATOR,
MREQ. EXECUTOR,
MREQ. CATEGORY,
MREQ. PARENT_CONTEXT_ID,
MREQ. CREATION_TS,
MREQ. TYPE
of PAS_REQUEST mreq
Cn PAS_CONTEXT
where mreq.id = cn.request_id
and mreq. DTYPE = "MAINREQUEST."
and mreq. TYPE in
(
'bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ',' bgc.tbf.repair.vap', ' bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ',' bgc.cbm ',' bgc.dar.e2etest.preparation', ' bgc.chc.polling '.
)
and cn. STATUS ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and CAST (cn. END_TS AS DATE) > = TO_DATE ('2014-05-06 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS)
and CAST (cn. END_TS AS DATE) < = TO_DATE ('2014-05-06 23:59:59 ',' ' YYYY-MM-DD HH24:MI:SS)
and cn.ID between the 20141999999999999 AND 20141800000000000
and mreq.ID between the 20141999999999999 AND 20141800000000000
Tips will be may not be necessary (proportional to the cardinalities need)
Select pc.id, pc.dtype, pc.version, pc.external_ref, pc.creation_ts, rq.type
from pas_case
as_request rq,
CN pas_context
where rq.case_id = pc.id
and rq.id = cn.request_id
and rq.dtype = 'MAINREQUEST. '
and rq.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',
'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and cn.creation_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')
and cn.creation_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">=>
-2nd request
with
main_request as
(select / * + materialize * /)
CN.ID as context_id, rq.type as main_req_type
of pas_request rq
Join
CN pas_context
On rq.id = cn.request_id
and rq.dtype = 'MAINREQUEST. '
and rq.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.chc.polling',
'bgc.tbf.repair.vap ',' bgc.dar.e2etest', ' bgc.dar.e2etest.intermediate.execution ',.
'bgc.cbm ','bgc.dar.e2etest.preparation '.
)
and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')
and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">=>
and cn.id between 20141800000000000 and 20141999999999999
and rq.id between 20141800000000000 and 20141999999999999
)
Select ra.id, ra.version, ra.request_id, ra.name, ra.value, ra.lob_id, ra.dtype, ra.creation_ts, task.main_req_type
of pas_requestattribute ra
Join
(select tsk.id, tsk.type, main_req.main_req_type
from pas_request tsk
Join
main_request main_req
On tsk.parent_context_id = main_req.context_id
and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.id between $$ low_id1 and $$ high_id1
) task
We ra.request_id = task.id
and ra.id between $$ low_id1 and $$ high_id1
Union
Select ra.id, ra.version, ra.request_id, ra.name, ra.value, ra.lob_id, ra.dtype, ra.creation_ts, main_req.type
of pas_requestattribute ra
Join
main_request main_req
On ra.request_id = main_req.context_id
-3rd request
Select rb.id, rb.dtype, rb.version, rb.type, rb.creation_ts, rb.task_id, rb.color, rb.global_result, task.main_req_type
of pas_resultblock rb
Join
(select tsk.id, tsk.type, main_req.main_req_type
from pas_request tsk
Join
(select cn.id as context_id, rq.type as main_req_type
of pas_request rq
Join
CN pas_context
On rq.id = cn.request_id
and rq.dtype = 'MAINREQUEST. '
and rq.type in ('bgc.dar.vap.resolution.advice ','bgc.dar.e2etest.execution ',
'bgc.tbf.repair.vap ','bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ','bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')
and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">=>
and cn.id between 20141800000000000 and 20141999999999999
and rq.id between 20141800000000000 and 20141999999999999
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.id between $$ low_id1 and $$ high_id1
) task
We rb.task_id = task.id
and rb.id between $$ low_id1 and $$ high_id1
where the type is null
or (type is not null
type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution ', ' bgc.tbf.repair.vap',
'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
)
-4th query
Select ri.id, ri.dtype, ri.version, ri.resultblock_id, ri.name, ri.value, ri.unit, ri.color, ri.lob_id.
RI.creation_ts, RI. Sequence, RI. DetailLevel, res_blk.main_req_type
of pas_resultitem ri
Join
(select rb.id, rb.type as rb_type, task.type as task_type, task.main_req_type)
of pas_resultblock rb
Join
(select main_req_type, tsk.id, tsk.type, main_req.)
from pas_request tsk
Join
(select cn.id as context_id, rq.type as main_req_type
of pas_request rq
Join
CN pas_context
On rq.id = cn.request_id
and rq.dtype = 'MAINREQUEST. '
and rq.type in ('bgc.dar.vap.resolution.advice ','bgc.dar.e2etest.execution ',
'bgc.tbf.repair.vap ','bgc.dar.e2etest ',.
'bgc.dar.e2etest.intermediate.execution ','bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')
and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">=>
and cn.id between 20141800000000000 and 20141999999999999
and rq.id between 20141800000000000 and 20141999999999999
) main_req
On tsk.parent_context_id = main_req.context_id
and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.id between 20141800000000000 and 20141999999999999
) task
We rb.task_id = task.id
and rb.id between 20141800000000000 and 20141999999999999
and rb.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',
'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
) res_blk
On ri.resultblock_id = res_blk.id
and ri.id between 20141800000000000 and 20141999999999999
where ri.name is null
or (ri.name is not null
and ri.name in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',
'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
)
-5th application
with
main_request as
(select / * + materialize * / )
mreq.ID, mreq.version, mreq.dtype, mreq.case_id, mreq.type, mreq.correlation_id, mreq. Initiator, mreq. Executor,
mreq. Category, mreq.parent_context_id, mreq.creation_ts, mreq.type
of pas_request mreq
Join
CN pas_context
On mreq.id = cn.request_id
and mreq.dtype = 'MAINREQUEST. '
and mreq.type in ('bgc.dar.vap.resolution.advice ',' bgc.dar.e2etest.execution', ' bgc.tbf.repair.vap',
'bgc.dar.e2etest ',' bgc.dar.e2etest.intermediate.execution', ' bgc.cbm ',.
'bgc.dar.e2etest.preparation ','bgc.chc.polling '.
)
and cn.status in ('FINISHED', 'CANCEL', 'TIMEOUT', 'ERROR')
and cn.end_ts > = to_timestamp ('2014-05-06 00:00:00 ',' yyyy-mm-dd hh24:mi:ss')
and cn.end_ts<= to_timestamp('2014-05-06="" 23:59:59.999999','yyyy-mm-dd="">=>
and cn.id between 20141800000000000 and 20141999999999999
and mreq.id between 20141800000000000 and 20141999999999999
)
Select tsk.id, tsk.version, tsk.dtype, tsk.case_id, tsk.type, tsk.correlation_id, tsk.initiator, tsk.executor,
TSK. Category, tsk.parent_context_id, tsk.creation_ts, main_req.main_req_type
from pas_request tsk
Join
main_request main_req
On tsk.parent_context_id = main_req.id
and tsk.dtype in ('ANALYSIS_TASK', 'DECISION_TASK')
and tsk.id between $$ low_id1 and $$ high_id1
Union
SELECT id, version, dtype, case_id, type, correlation_id, initiator, executor,
category, type parent_context_id, creation_ts
of main_request
Concerning
Etbin
-
Retrieve data in pl/sql table type
Hello
I am facing problem in the following sql query,
How should I display all records.
declare
tab type is the emp9% rowtype index directory table.
e_tab tab.
Start
Select empno, ename, job, mgr, sal, comm, deptno bulk collect into emp9 e_tab;
for x in e_tab.first... e_tab. Last
loop
dbms_output.put_line (e_tab (x));
end loop;
end;
I get the argument type error or wron number of in the DBMS... statement.
How should I fix it?
Published by: 923315 on March 30, 2012 12:50Yes, he accepts a single parameter, but it can always be expression (as the concatenation: val1 | val2 | val3). In your case (.ename e_tab (x) |) ' ' || e_tab (x) .sal
-
Statements to generate INSERT automatic SQL table data
Is there a way to Oracle to automatically generate INSERTION of data in the table sql statements using PL/SQL or Oracle OEM developer?
Thank you very much.
See you soon.
RohanHello
Data that can be selected in different types, try using the tool to open a predefined sample and see.
Kind regards
-
Issue when inserting into a table using sequence in Oracle 11 g Rel 2
Hi all
I am facing problem when I insert sequence values in my table.
When inserting, my sequence does not begin with the beginning with the value.
Example Script
CREATE SEQUENCE xyz_seq
START WITH 1
INCREMENT BY 1
NOMAXVALUE
MINVALUE 1
NOCYCLE
NOCACHE
ALL;
create table abc (a number not null);
insert into abc (xyz_seq.nextval) values;
Select *.
ABC;
xyz_seq sequence of fall;
drop table abc;
Output
Order of creation.
Table created.
1 line of creation.
ONE
----------
2
1 selected line.
Sequence has fallen.
Deleted table.
I can't understand why this is inserting value 2, when my sequence should start at 1.
To overcome that road, I implemented a different logic.
Example of
CREATE SEQUENCE xyz_seq
START WITH 1
INCREMENT BY 1
NOMAXVALUE
MINVALUE 1
NOCYCLE
NOCACHE
ALL;
create table abc (a number not null);
declare
x number (1): = xyz_seq.nextval;
Start
insert into abc (x) values.
end;
Select *.
ABC;
xyz_seq sequence of fall;
drop table abc;
Output
Order of creation.
Table created.
PL/SQL procedure successfully completed.
ONE
----------
1
1 selected line.
Sequence has fallen.
Deleted table.
However, my question remains why referring to the sequence.nextval in my insert does not return me the beginning with the value.
Kind regards
RishiThat's what says the doc ;
If you attempt to insert a sequence value into a table that uses deferred segment creation, the first value that the sequence returns will be skipped.
It ignores the value 1 and returns 2.
-
Lines in bulk insert in the table of the adf.
Hello
My requirement is to insert rows selected from a VO in a new OT at the same time.
Can anyone guide me on this please?
Thanks in advance.
Not really sure what you are after.
If you say that you have the details in a readOnly VO and now you must insert in a based EO VO, then Yes, you must go through the lines.
You can refer to the blog below which speaks the lines of cloning.
https://blogs.Oracle.com/vijaymohan/entry/cloning_a_view_object_rows_adfbc_way
It will be useful.
See you soon
AJ
-
Hello
Version 10g
I need to get an array of 100 recordings in pl/sql procedure.
The table is built on columns.
Then I need bulk insert into the table.
Question: Is it possible to get a table in the stored procedure?
Thank youYes you can get it. Check the code below.
SQL> create type trec is object (a number, b number); 2 / Type created. SQL> create type tlist is table of trec; 2 / Type created. SQL> create table coltab(col1 number, col2 number, entry_date date); Table created. SQL> ed Wrote file afiedt.buf 1 create or replace procedure arraytest (p tlist) is 2 begin 3 for i in p.first..p.last 4 loop 5 insert into coltab values 6 (p(i).a,p(i).b,sysdate); 7 end loop; 8* end; SQL> / Procedure created. -----------Testing-------------------- SQL> declare 2 l tlist := tlist(trec(1,2),trec(4,3)); 3 begin 4 arraytest(l); 5 end; 6 / PL/SQL procedure successfully completed. SQL> SQL> SQL> select * from coltab; COL1 COL2 ENTRY_DAT ---------- ---------- --------- 1 2 04-AUG-10 4 3 04-AUG-10
If you do not use the concept of line, try this. This works in a similar way.
create or replace procedure arraytest (p tlist) is begin insert into coltab select t1.*, sysdate from table(p) t1; end; /
-
Bulk insert in an external table
Hi, I get the error ora-29913, ora-01410 trying to do a bulk insert of external table
INSERT
IN CORE_TB_LOG
(SELECT 'MODEL', 'ARCH_BH_MODEL', ROWID, "MODEL-D-000000001', - 45, 'A', SYSDATE, 'R'")
OF ARCH_BH_MODEL1
WHERE length (MOD_XCODIGO) > 10)
INSERT
*
ERROR on line 1:
ORA-29913: error in executing ODCIEXTTABLEFETCH legend
ORA-01410: invalid ROWID
ARCH_BH_MODEL1 is the external table.
What's wrong?
Thank you.
Hello
There is no ROWID in external tables.
It makes sense: ROWID identifies where a line is stored in the database; It shows the data file and the block number in this file.
External tables are not stored in the database. They exist independently of any data file in the database. The concept of an Oracle block does not apply to them.
Why would you copy the ROWID, even if you could?
Apart from ROWID and SYSDATE, you select only literals. You don't want to select all the real data of the external table?
What is the big picture here? Post a small example of data (a CREATE TABLE statement and a small data file for the external table) and the desired results from these sample data (in other words, what core_tb_log must contain after INSERTION is complete.) Explain how you get these results from data provided.
Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?
-
OracleCommand - insertion of configurable tables memory leak...
Hello
I have a .net application batch bulk inserts into a table using parameterized paintings sent to a stored proc.
The pseudo-device application looks like this:
For each report
-Recover 14 K of data lines
-create tables based on data
-specify link count
-connect
-OracleCommand.ExecuteNonQuery <-this IS WHERE MEMORY JUMPS AND NEVER CAME OUT
-Connection.Close)
-Connection.Dispose)
-OracleCommand.Dispose)
Next report
At this point I'm very nearly causing a System.OutOfMemoryException exception
If I add more aspects to the process that I don't know that it will happen.
IS THERE A WAY TO RECOVER THIS MEMORY OTHER THAN THE WAY I DO? I TRIED SEVERAL WAYS (using OracleCommand..., OracleCommand = null, OracleCommand.dispose) BUT IT's NOT FACT NO DIFFERENCE.
Thank you
JoeHello
PACO is the version of the specific customer. 11g odp requires client 11g, 10g OPD requires 10g client etc. I'm surprised your app works even based on what you said (check the forums initializer Exception Type, you'll see a mess of positions).
In any case, the answer is, you need to install a new Oracle and ODP client to use the new ODP. There is also a bundle of xcopy from 11 g that makes it a little less painless.
It will be useful,
Greg -
Insert rows in the PL/SQl table
Hello
I have a PL/SQl table that I filled through bulk collect and now I'm trying to loop through the table (actually quite a few nested loops)... Now in one of my curls, I might need to insert a new row by splitting the field in the existing row in the table. Can I insert the line in the pl/sql table in the loop without affecting the "FOR i IN tab.first... Tab.Last' loop?
Also, what would be the index of such a line inserted into the table. Can I access it with tab.last + 1 (doesn't look like it can be done if I insert into various levels of loops).
OR
If I insert the lines insde loops nested, then I can access the new lines as soon as I close all the loops and open a new loop? The new lines will be at the last table.
Any help will be appreciated...The expression v_arr. LAST gives the index of the last entry, so you can refer to this element as
v_arr(v_arr.LAST)
Then the attributes of this element will be
v_arr(v_arr.LAST).attr
for example
DECLARE TYPE table_defs_tt IS TABLE OF user_tables%ROWTYPE INDEX BY PLS_INTEGER; v_mytables table_defs_tt; BEGIN SELECT * BULK COLLECT INTO v_mytables FROM user_tables WHERE ROWNUM <= 100; DBMS_OUTPUT.PUT_LINE(v_mytables(v_mytables.LAST).table_name); END;
-
How to avoid performance issues in PL/SQL?
How to avoid performance issues in PL/SQL?
According to my knowledge, below a few points to avoid performance problems in PL/SQL.
Is there any other point to avoid performance problems?
1. use FORALL instead of the FORUM and GATHER in BULK to avoid a loop several times.
2. RUN IMMEDIATE is faster than DBMS_SQL
3. use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of keeping a copy of OUT is avoided.Thanks for your comments Justin!
BC explains things right on part SQL...
http://www.DBA-Oracle.com/art_sql_tune.htm
-
Performance problem when inserting in an indexed table space with JDBC
We have a table named 'feature' that has a "sdo_geometry" column, and we created the spatial index on this column,
CREATE TABLE (ID, desc varchar, sdo_gemotry oshape) feature
CREATE INDEX feature_sp_idx ON feature (oshape) INDEXTYPE IS MDSYS. SPATIAL_INDEX;
Then we executed following SQL to insert some 800 records in this table (we tried this using the DB Viewer and)
our Java application, both of them were using JDBC driver to connect to the database oracle 11 g 2).
insert into feature (id, desc, oshape) values (1001, xxx, xxxxx);
insert into a values (id, desc, oshape) feature (1002, xxx, xxxxx);
...........................
insert into a values (id, desc, oshape) feature (1800, xxx, xxxxx);
We met the same problem as this topic
Performance of the insert with spatial index
It takes almost 1 dry for inserting a record, compared with 50 records inserted per second without spatial index.
which is 50 x slow performance when you perform the insertion with the spatial index.
However, when we copy and paste these scripts inserted in Oracle Client(same test and same table with spatial index), we got a completely different performance results:
more than 50 records inserted in 1 seconds, as fast as the insertion without having to build the spatial index.
Is it because that the Oracle Client not using JDBC? Perhaps JDBC has been something bad when updating of these tables indexed on the space.
Edited by: 860605 09/19/2011 18:57
Edited by: 860605 09/19/2011 18:58
Published by: 860605 on 19/09/2011 19:00JDBC normally use autocommit. So each insert can leads to a commit.
I know not all customer Oracle. In sqlplus, insert is just an insert,
and you run "commit" to commit your changes explicitly.
So maybe that's the reason. -
collect two pl/sql table dimensions and in bulk
Hi, I want to create a pl/sql table of two-dimensional characters. I would like to know if I can use in bulk accumulate in this case in a select statement
can you give us examples?
t_collection('flower) ('water') should return a value in the table after that I have bulk collect two-dimensional pl/sql tableelmasduro wrote:
Hi, I want to create a pl/sql table of two-dimensional characters. I would like to know if I can use in bulk accumulate in this case in a select statement
can you give us examples?t_collection('flower) ('water') should return a value in the table after that I have bulk collect two-dimensional pl/sql table
I don't think that COLLECT in BULK supports complex tables like the one descrbed you - unless you use arrays of objects. You can probably have an array of types of complex objects, but I did not do that.
If you can not get to COLLECT it in BULK for work use nested loops to put values in the nested tables.
If the number of items in the 'internal' table is fixed you pouvez use BULK COLLECT with an array of records.
-
Facing the issue when inserting data by region table
Dear all,
I have a region of the table which will be created initially five rows and im generating a sequence so that five lines simultaneously. First insertion was smooth without any issue.when I train for the second time, loading the page while it shows 10 records and then the third time, she displays 20 records in the table. He brings the existing record that is inserted into the table. Please get a solution to solve. The script below is my AM insert method
If (! vo.isPreparedForExecution ())
{
vo.executeQuery ();
}
VO. Last();
int fetchedrowcount = vo.getFetchedRowCount ();
System.out.println ("number of rows->" + vo.getFetchedRowCount ());
for (int i = 1; i < = fetchedrowcount; i ++) {}
vo.setMaxFetchSize (0);
VO. Last();
VO. Next();
Line OARow = (OARow) vo.createRow ();
vo.insertRow (row);
row.setNewRowState (Row.STATUS_INITIALIZED);
row.setAttribute ("ClTransId", getOADBTransaction () .getSequenceValue ("apps.xxhrq_chcklist_trans_s"));
}
Heepth,
The logic is simple.
When the page initially loads, it brings 5 lines in your outer join function, then your code create another 5 rows based on the fetchedRowCount which is 5. All together, it makes 10.
Second time when the page loads, the query returns (5 + 5) 10 rows and your code create another 10 rows based on the fetchedRowCount which is 10 this time. All together, it makes 20.
It is clear now?
Now go ahead and implement the solution I proposed. If all good, would you please close the thread by checking the useful and accurate answers. If you have questions let us know.
See you soon
AJ
Maybe you are looking for
-
Apple Watch 2 will be able to follow the elevation/altitude
I need to know if Apple Watch 2 will be able to follow the elevation / altitude without having my phone. IM wanting to buy a watch for Strava
-
Problem with JavaScript coding.
I'm new to JavaScript and even coding of the site. I am filling a form dynamically and manage with FF7. To begin I couldn't even pass the name of the form as an argument with FF7. After simplifying the code to see what is fundamentally wrong, I came
-
Should I update my Bios?
I have an old DV6707us. I bought a new computer and when it failed, I took my old laptop and replace the hard drive has failed. The original system is Windows Vista. A couple of months he has reformatted the new hard drive and installed Win7. My qu
-
Installation of printer using Vista
After using printing HP and Dr. Scan, I uninstalled all my Photosmart D110A drivers and software by its recommendation. When I tried to reinstall the HP site fom, installation continiously has crashed or locked up. Then in my last attempt, a message
-
My 3 year old Pavilion p6207, Windows 7, office top of page HDD, HDD Seagate Barracuda 500 GB, 7200 RPM turns out to be dead by the HP technical support. They offered one for $199. So I ordered. That the order has been processed they said, oops, that