Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Fabian.

Asked: June 20, 2011 - 12:57 pm UTC

Last updated: November 29, 2012 - 7:19 am UTC

Version: 10.2.0.3

Viewed 10K+ times! This question is

You Asked

Hi Tom (and other readers)
I'm searching for solution how to implement parallel select from remote site.
So my question is what are possibilities to :
select * from big_partitioned_parallel_table@remote;
or
dbms_mview.refresh('VIEW_BUILD_ON_REMOTE_TABLES');
was not SERIAL_FROM_REMOTE but some kind of "PARALLEL_FROM_REMOTE".
I guess some kind of solution could be using DBMS_DEFER_SYS.SCHEDULE_PUSH (?), but i need to organize it without using SYS account and definitely on destination not source site. And by the way maybe you could answer the question if DBMS_DEFER_SYS can be used as a solution (or there is no sense to investigate it because it has other usage)
thanks and regards,

Ok, more details:
create table LOCAL_TABLE parallel as
select * from big_partitioned_parallel_table@remote;
first step in explain plan would be:
REMOTE REMOTE SERIAL_FROM_REMOTE big_partitioned_parallel_table remote Bytes: 2,272 Cardinality: 1
The second step is
PX SEND ROUND-ROBIN PARALLEL_FROM_SERIAL SYS.:TQ10000 Bytes: 2,272 Cardinality: 1
which is using parallel but in one thread, ie no parallel loading.
So is it possible to parallelize first step (selecting from remote table) to get whole process faster.
The same is with refreshing materialized views which goes in serial if table is remote one.
So the question is -- can we make any loading of segments by database link in parallel mode (in more than one thread)?

and Tom said...

You cannot do "parallel" over a single database link, you can do parallel on each end of the dblink, but as you have only one network pipe - it'll be serial over that. you'll have to break the job out into smaller pieces yourself.

In 11g, you could use dbms_parallel_execute, but in 10g - you'll have to "do it yourself"

The easiest would be to set up a job (dbms_job, dbms_scheduler) for each partition and do a load in that job. If the local table is partitioned the same way - each job would use dynamic sql to load its partition, something like:

insert /*+ append */ into localtable partition( PNAME )
select * from remotetable@dblink partition(PNAME)


If the local table is NOT partitioned, you will NOT be able to use the APPEND hint - as they would all end up serializing on each other.

see also
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:10498431232211


Rating

  (7 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Fabian, June 22, 2011 - 1:19 am UTC

ok, little confusing that one network pipe could be used in parallel in 11g but not in 10g ;-)
but of course I understand the answer and thanks -- I won't waiste time for searching not existing solutions.
Tom Kyte
June 22, 2011 - 10:25 am UTC

where did you read it is different in 11g?

parallel select from remote site

umar, June 24, 2011 - 2:24 am UTC

Hi Tom,
Can we use /*+ parallel (a,4) */ hint for accessing remote table in parallel. Though while fetching data over DB link, it would be serialized, but to extract data from remote DB can it run in parallel? will this hint be useful along with driving_site() hint?
Tom Kyte
June 24, 2011 - 8:51 am UTC

you can run the remote query in parallel - yes. driving site only works with READ queries. If you have an insert as select, it doesn't do anything, it doesn't work.

Oracle does not support remote select from partition

Alexander, March 19, 2012 - 4:44 am UTC

Hi, Tom.

You wrote
"
insert /*+ append */ into localtable partition( PNAME )
select * from remotetable@dblink partition(PNAME)
"

But Oracle does not support remote select from partition
ORA-14100...
Tom Kyte
March 19, 2012 - 10:19 am UTC

You can easily use the partition key on that one - you don't need it to avoid the locking or anything.


Or a remote view.

dblink and parallel hint

karla, October 17, 2012 - 4:12 pm UTC

Hi tom,

I have problems with a insert..select and remote table
...like this

insert into table1_big
select/*+ PARALLEL(8) */
campo1, campo2
from table2_big@dblink;

when i saw the execution, this query do not show me the parallel sesions

when put this query in the local db...like this:

insert into table1_big
select/*+ PARALLEL(8) */
campo1, campo2
from table2_big--- not need the dblink is in the local table

in this case, it show me the parrallel sesion..

what is wrong?? what is the problem??

the table are very big and it have partition
Tom Kyte
October 18, 2012 - 7:19 am UTC

well, all of the data is going to be serialized over the database link - it can "parallel" on the back end - but all of the output will be funneled into a single database link stream. It is the nature of a database link - you cannot have many of them opened automagically for a parallel operation - you'll have just one connection.


Suggest you look into transporting the data if it is really large, that way you don't have to load anything - just copy datafiles.


or, if both tables are partitioned the same way you can fire off multiple sessions with

insert /*+ APPEND */ into table1_big partition(X) select ... from table@remote where <partition condition>;


for each partition simultaneously - as long as you use the partition extended name on the insert - you can do simultaneous direct path loads.

Big problem with process

A reader, November 08, 2012 - 5:25 pm UTC

hi again Tom

i have a process like this:

insert/*+ append parallel(15)*/ all
into big_partition_table1
into big_partition_table2
into big_partition_table3
select /*+ parallel(15)*/
* /*...( several fields)*/
from big_tabla_locally a
left join small_tabla1 locally b
on ( a.key = b.key)
left join small_tabla2 locally c
on ( a.key = c.key)
left join small_tabla3 locally d
on ( a.key = d.key)
..
left join small_tabla16 locally x
on ( a.key = x.key)
where a.particion_fiel = p_parameter

this big_tabla_locally load 40 million rows every day,
i am working on a super server, but recently this process took an hour, now takes 10 hours and it never ends

what is the problem? helpme please..
Tom Kyte
November 09, 2012 - 6:29 am UTC

trace it, use ASH information if you have access to it. see what it is doing, look for historical plan changes.

Paralle across dblink

mahendra, November 23, 2012 - 9:41 am UTC

I am doing merge on a table across dblink
the table is huge 15 million
basel_data is accessed across a dblink while Account_Product_History is a local table and is 3 million records.
when i add a parallel hint ,
/*+ PARALLEL(b, 8) */
it gives error. what is going wrong here?
whereas the same thing works when all the tables are local, without a dblink!
i am using oracle 10g



MERGE /*+ PARALLEL(b, 8) */
INTO basel_data b
USING (
with xxx as
(select bd.*,
case when accph_act_code_orig ='CONV' then NULL
when accph_act_code_orig is NULL then bd_act_code
else accph_act_code_orig
end accph_act_code_orig
,first_value(bd_book_source) over(PARTITION by bd_account_no order by bd_period desc) as derived_book_source
,first_value(bd_book_code) over(PARTITION by bd_account_no order by bd_period desc) as derived_book_code
from basel_data bd
,(select distinct accph_account_no accph_account_no
,first_value(Accph_Act_Code_from)
over (partition by accph_account_no order by Accph_Transfer_From_Date, Accph_Subacc_No ) as accph_act_code_orig
from Account_Product_History ) qry
where qry.accph_account_no(+)=bd_account_no
)
select
xxx.bd_account_no, xxx.bd_period,
xxx.derived_book_source, xxx.derived_book_code,
--xxx.*,
NVL(ps1.prst_scheme_type,'STAN') prst_scheme_type_orig,
ps2.prst_scheme_type prst_scheme_type_curr,
case when (ps1.prst_scheme_type is null and accph_act_code_orig is null)
then Null
else NVL(px1.pacx_product_code,px2.pacx_product_code)
end pacx_product_code_orig,
px2.pacx_product_code pacx_product_code_curr
from xxx
,product_act_code_xref px1
,product_stype_availability ps1
,product_act_code_xref px2
,product_stype_availability ps2
where px1.pacx_act_code(+) = xxx.accph_act_code_orig
and ps1.prst_pr_product_code(+) = px1.pacx_product_code
and px2.pacx_act_code(+) = xxx.bd_act_code ----second join
and ps2.prst_pr_product_code(+) = px2.pacx_product_code
) e
ON (b.bd_account_no = e.bd_account_no and b.bd_period=e.bd_period )
WHEN MATCHED THEN
UPDATE SET
b.bd_prst_scheme_type_orig =e.prst_scheme_type_orig ,
b.bd_prst_scheme_type_curr =e.prst_scheme_type_curr ,
b.bd_pacx_product_code_orig =e.pacx_product_code_orig ,
b.bd_pacx_product_code_curr =e.pacx_product_code_curr
, b.bd_book_code =e.derived_book_code
, b.bd_book_source =e.derived_book_source;

Tom Kyte
November 29, 2012 - 7:19 am UTC

my car won't start.....


nope, I won't tell you what sound it makes, what kind of car it is, what the dashboard says - nope, not at all. You should be able to figure it out.

when you tell me why my car won't start - I'll tell you all about your issue.


because we both have about the same amount of information. You know I have a car that won't start - I know you have a query that won't run.



I will say this - if you are updating millions of rows - you almost certainly DO NOT want to use DML, you want to use DDL (create table as select).


good

A reader, May 01, 2013 - 3:22 pm UTC

Good input. Thanks Tom.

More to Explore

Hints

Need more information on hints? Check out the complete hint descriptions