BULK COLLECT issue [message #555276] |
Tue, 22 May 2012 21:47  |
andy huang
Messages: 498 Registered: July 2011
|
Senior Member |
|
|
Dear all,
The SQL1 and SQL2 are do the same thing that get data into temp table(nologging mode),the SQL2 is slower than SQL1,why?
SQL1:
insert /*+append */into mail_batchsendnotify_tmp
(
mobilenum,
ispsid,
readcount,
seqno
)
select /*+PARALLEL(c,2) */
mobilenum,
c.ispsid,
c.ReadCount,
seqno
from odsview.vw_mail_batch_notify c
where c.modifytime >= trunc(Sysdate)
and c.modifytime < trunc(Sysdate) + 1
SQL2:
Declare
Cursor cur_batch_notify_data
Is
select /*+PARALLEL(c,2)*/
c.mobilenum As usernumber,
c.ispsid,
c.seqno,
c.ReadCount
from odsview.vw_mail_batch_notify c
where c.modifytime >= trunc(Sysdate)
and c.modifytime < trunc(Sysdate) + 1
;
TYPE type_table_SEQNO1 IS TABLE OF mail_batchsendnotify_tmp.seqno%type INDEX BY BINARY_INTEGER; --
table_SEQNO1 type_table_SEQNO1;
TYPE type_table_usernumber1 IS TABLE OF mail_batchsendnotify_tmp.MOBILENUM%type INDEX BY BINARY_INTEGER; --
table_usernumber type_table_usernumber1;
TYPE type_table_ispsid IS TABLE OF oss03.oss_mail_deliver_effective_tp.ispsid%type INDEX BY BINARY_INTEGER; --
table_ispsid type_table_ispsid;
TYPE type_table_readcount IS TABLE OF Number INDEX BY BINARY_INTEGER;
table_readcount type_table_readcount;
Type type_table_provcode Is Table Of Number INDEX BY BINARY_INTEGER;
l_type_table_provcode type_table_provcode;
Begin
OPEN cur_batch_notify_data;
LOOP
FETCH cur_batch_notify_data BULK COLLECT
INTO table_usernumber,
table_ispsid,
table_seqno1,
table_readcount LIMIT 3000;
FORALL i IN 1 .. table_usernumber.count
insert /*+append*/into mail_batchsendnotify_tmp
(
mobilenum,
ispsid,
seqno,
readcount
)
Values
(
table_usernumber(i),
table_ispsid(i),
table_seqno1(i),
table_readcount(i)
);
commit;
EXIT WHEN cur_batch_notify_data%NOTFOUND OR cur_batch_notify_data%NOTFOUND IS NULL;
END LOOP;
CLOSE cur_batch_notify_data;
End;
|
|
|
|
Re: BULK COLLECT issue [message #555280 is a reply to message #555278] |
Tue, 22 May 2012 22:24   |
andy huang
Messages: 498 Registered: July 2011
|
Senior Member |
|
|
Thanks,
BlackSwan, the SQL1 and the SQL2 use the same sql just as the flowing,the difference between them is SQL1 just on a insert sql,and SQL2 use the bulk collect. can you tell me the detail about SQL1 is faster than SQL2?
The same SQL:
select /*+PARALLEL(c,2)*/
c.mobilenum As usernumber,
c.ispsid,
c.seqno,
c.ReadCount
from odsview.vw_mail_batch_notify c
where c.modifytime >= trunc(Sysdate)
and c.modifytime < trunc(Sysdate) + 1
;
|
|
|
|
|
|
|
|
|
Re: BULK COLLECT issue [message #555313 is a reply to message #555295] |
Wed, 23 May 2012 03:13   |
prashant_ora
Messages: 196 Registered: July 2010
|
Senior Member |
|
|
:PARALLEL does not exist in your PL/SQL version
If we use statement inside the pl/sql block then also parrale will not be used?
execute immediate ('alter session enable parallel dml');
Please suggest....
|
|
|
|
Re: BULK COLLECT issue [message #555319 is a reply to message #555316] |
Wed, 23 May 2012 03:37   |
prashant_ora
Messages: 196 Registered: July 2010
|
Senior Member |
|
|
ok....
but suppose i have a big pl/sql block and lots of select query is there for different buisness requirement and we want to use parallel hint, so how we can use, any method to use it and what about the stored proc, in side the whether parallel can use it or not?
|
|
|
|
|
|