Populate
A reader, December 29, 2011 - 4:06 am UTC
Hi Tom,
lets say we have 2 tables XYZ and XYZ_dummy.
In every batch process we truncate table XYZ_dummy and insert from table XYZ.The row count of table XYZ is 39500014 .This run in multiple streams.Can you tell what is fastest way we can do this ??
If we drop table and create XYZ_dummy as select * from XYZ will be faster than insert ???
December 29, 2011 - 11:19 am UTC
how can a truncate and insert take place in multiple streams?
The fastest way to populate this table would probably be:
a) truncate it
b) insert /*+ append */ into it using PDML (parallel DML)
in a single stream, we do the parallel stuff for you.
that can be done without generating any redo for the table if the dummy table is nologging. It will also bypass undo generation for the table as well.
A reader, December 29, 2011 - 12:03 pm UTC
Hi Tom,
Sorry.Truncate table is not in multiple streams.Only insert in multiple streams.AS we are already running in multiple streams do we really need PDML ??
we can use "truncate table XYZ drop storage" instead of truncate table XYZ and then insert with /*+append*/.
Does it impact to select query if we use append hint after drop storage ???
December 29, 2011 - 1:22 pm UTC
Why are you running in multiple streams something which is done trivially in a single statement.
Your procedural code that splits up this insert will almost be definition include alot of overhead a single sql statement will not.
If you decide to change the degree of parallelism we can do it in a millisecond using pdml ... how about your code?
We can do direct path loading... can you? You cannot do it in parallel unless you are writing in oci. And if you are in oci .... well you've done it wrong since you wrote a ton of code when one line would do...
Can you skip the undo redo generation?
Why did you write code that would be slower, use more runtime resources, required debugging, and requires maintenance over time?
A reader, December 29, 2011 - 10:43 pm UTC
Hi Tom,
Only Below is the query in code under a function which run in multiple stream.It takes 76.65 minute to complete.Total record under the view is 2735849.
Here acct_hoff is a view of 4 tables.Almost all the record are flg_mnt_status = 'A'
mis_acct_hoff is a table.
INSERT INTO mis_acct_hoff
SELECT amt_sched_princ_bal, amt_instal_arrears, dat_acct_close,
flg_mnt_status, cod_cc_brn, cod_acct_no, cod_prod,
cod_cust_id, dat_of_maturity, cod_ccy, rat_int_current,
amt_arrears_princ, amt_arrears_interest, amt_arrears_chg,
cod_acct_stat, flg_past_due_status, amt_face_value,
amt_princ_balance, flg_accr_status, dat_last_renew,
dat_last_due, amt_disbursed, amt_arrears_charges,
cod_user_stat, amt_net_disbursed, amt_arrears_nonacc, amt_accr_computed,
cod_remitter_acct, dat_acct_open, bal_book, rat_penalty_int, nam_cust_shrt
FROM acct_hoff b
WHERE b.flg_mnt_status = 'A'
AND EXISTS ( SELECT 1
FROM mis_ctrl z
WHERE z.cod_cc_brn = b.cod_cc_brn
AND z.cod_stream_id = var_actual_cod_stream_id
AND z.cod_prog_id = 'MISC');
so we can replace with below and remove streaming :
INSERT /*+append*/INTO mis_acct_hoff
SELECT /*+parallel(b,40)*/
amt_sched_princ_bal, amt_instal_arrears, dat_acct_close,
flg_mnt_status, cod_cc_brn, cod_acct_no, cod_prod,
cod_cust_id, dat_of_maturity, cod_ccy, rat_int_current,
amt_arrears_princ, amt_arrears_interest, amt_arrears_chg,
cod_acct_stat, flg_past_due_status, amt_face_value,
amt_princ_balance, flg_accr_status, dat_last_renew,
dat_last_due, amt_disbursed, amt_arrears_charges,
cod_user_stat, amt_net_disbursed, amt_arrears_nonacc, amt_accr_computed,
cod_remitter_acct, dat_acct_open, bal_book, rat_penalty_int, nam_cust_shrt
FROM acct_hoff b
WHERE b.flg_mnt_status = 'A'
AND EXISTS ( SELECT 1
FROM mis_ctrl z
WHERE z.cod_cc_brn = b.cod_cc_brn
AND z.cod_stream_id = var_actual_cod_stream_id
AND z.cod_prog_id = 'MISC');
Yes,we can skip the undo redo generation.
How can we do direct path loading ?? Please explain.
This code was written earlier.Due to performance issue i am looking into this.Please help.
December 30, 2011 - 10:54 am UTC
... Yes,we can skip the undo redo generation.
...
IF and ONLY IF you use a single sql statement with append, you cannot use append in your multiple streams. I know for a fact that right now YOU CANNOT skip undo and redo.
/*+ APPEND */ is a direct path load.
http://www.oracle.com/pls/db112/search?word=parallel+direct+path+insert&partno= I do not think you will be using the sql you said you would use. It still seems to have a reference to some stream_id which you WILL NOT be using anymore. You will have a single session, using parallel DML, to achieve in a single line of code what is now encoded into a big program.
A reader, December 29, 2011 - 10:51 pm UTC
Hi Tom,
Please ignore above comment
Only Below is the query in code under a function which run in multiple stream.It takes 76.65
minute to complete.Total record under the view is 2735849.
Here acct_hoff is a view of 4 tables.Almost all the record are flg_mnt_status = 'A'
mis_acct_hoff is a table.
INSERT INTO mis_acct_hoff
SELECT amt_sched_princ_bal, amt_instal_arrears, dat_acct_close,
flg_mnt_status, cod_cc_brn, cod_acct_no, cod_prod,
cod_cust_id, dat_of_maturity, cod_ccy, rat_int_current,
amt_arrears_princ, amt_arrears_interest, amt_arrears_chg,
cod_acct_stat, flg_past_due_status, amt_face_value,
amt_princ_balance, flg_accr_status, dat_last_renew,
dat_last_due, amt_disbursed, amt_arrears_charges,
cod_user_stat, amt_net_disbursed, amt_arrears_nonacc, amt_accr_computed,
cod_remitter_acct, dat_acct_open, bal_book, rat_penalty_int, nam_cust_shrt
FROM acct_hoff b
WHERE b.flg_mnt_status = 'A'
AND EXISTS ( SELECT 1
FROM mis_ctrl z
WHERE z.cod_cc_brn = b.cod_cc_brn
AND z.cod_stream_id = var_actual_cod_stream_id
AND z.cod_prog_id = 'MISC');
so we can replace with below and remove streaming :
INSERT /*+append*/INTO mis_acct_hoff
SELECT /*+parallel(b,40)*/
amt_sched_princ_bal, amt_instal_arrears, dat_acct_close,
flg_mnt_status, cod_cc_brn, cod_acct_no, cod_prod,
cod_cust_id, dat_of_maturity, cod_ccy, rat_int_current,
amt_arrears_princ, amt_arrears_interest, amt_arrears_chg,
cod_acct_stat, flg_past_due_status, amt_face_value,
amt_princ_balance, flg_accr_status, dat_last_renew,
dat_last_due, amt_disbursed, amt_arrears_charges,
cod_user_stat, amt_net_disbursed, amt_arrears_nonacc, amt_accr_computed,
cod_remitter_acct, dat_acct_open, bal_book, rat_penalty_int, nam_cust_shrt
FROM acct_hoff b
WHERE b.flg_mnt_status = 'A'
AND EXISTS ( SELECT 1
FROM mis_ctrl z
WHERE z.cod_cc_brn = b.cod_cc_brn
AND z.cod_stream_id = var_actual_cod_stream_id
AND z.cod_prog_id = 'MISC');
Yes,we can skip the undo redo generation.
Yes can we do direct path loading by using hint append .But is it going to impact select query in performance wise ???
This code was written earlier.Due to performance issue i am looking into this.Please help.
December 30, 2011 - 10:55 am UTC
you cannot use append in multiple sessions - the append will lock the table, you can only use that append hint if you do it right - a single session...
append
A reader, December 30, 2011 - 11:23 am UTC
Hi Tom,
Yes will remove the multiple streams.
if we do following things it will have better than multiple streams :
1. use /*+append*/ on insert query
2./*+parallel(40)*/ on select query
3.alter table mis_acct_hoff nologging
December 30, 2011 - 11:41 am UTC
read the link i sent to you above, everything you want/need to do is fully explained in the documentation, read it all before you proceed.
Oracle Sessions and pga
vinod, July 13, 2012 - 8:54 am UTC
Hello Tom,
Please let me know how much pga_agg_target i should set for 500 sessions
Or in other way if have 2 gb pga how much sessions it will support without any issue
thanks
July 16, 2012 - 3:30 pm UTC
so, do you have 50 cpu cores? (500 sessions is probably way too many...)
http://www.youtube.com/watch?v=xNDnVOCdvQ0 anyway - the only answer anyone can give you is:
it depends.
do you sort a lot of rows frequently?
do you do tons of big hash joins?
do you do large bitmap index merges?
do you have an average of 2 active sessions?
do you have an average of 200 active sessions?
do you mostly use indexes to access 10 or so rows per query?
do you mostly use full scans to process tons of rows per query?
and so on - think about it, no one could answer this. No one.
What you can do is start with something you feel is reasonable - you know what your queries do, you know how many should be active at the same exact time approximately, you can take a first good guess and then watch the pga aggregate advisor (statspack or AWR report) and see what it says over time.
Oracle Sessions and pga
vinod, July 19, 2012 - 3:13 am UTC
Thanks Tom,
To add at some time maximum concurrent sessions can be 450
on average say have 300 concurrent sessions
its 10g rel 2 on rhel,20 gb ram,8 gb sga,1.8 gb pga
pga statistics show pga hit 53% and it indicate it will
be same until 8gb pga,is that optimum
digdeep, April 03, 2013 - 3:51 am UTC
Hello, I'm a fresh to Oracle.
I'm don't know that in the statement:
"dbms_job.submit( l_job, 'p(JOB);' );"
where is the parameter 'JOB' comes from ????
Thank you so much.
April 22, 2013 - 1:46 pm UTC
digdeep, April 03, 2013 - 4:42 am UTC
Hello, I'm already know that in the statement:
dbms_job.submit( l_job, 'p(JOB);' );
the parameter JOB equals to l_job.
Am I right? Thank you.
April 22, 2013 - 1:47 pm UTC