并行运行/执行多个过程 - Oracle PL/SQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34947855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:08:31  来源:igfitidea点击:

Run/execute multiple procedures in Parallel - Oracle PL/SQL

oracleplsqloracle11gparallel-processingdbms-scheduler

提问by Ankur Bhutani

I have an Activity table which is getting all the table events of the system. Events like new orders, insertion/deletion on all the system tables will be inserted into this table. So, the no of events/sec is really huge for Activity table.

我有一个活动表,它正在获取系统的所有表事件。新订单、所有系统表上的插入/删除等事件都将插入到该表中。因此,活动表的事件数/秒非常大。

Now, I want to process the incoming events based on the business logic depending on the table responsible for raising the event. Every table may have different procedure to do the processing.

现在,我想根据负责引发事件的表根据业务逻辑处理传入事件。每个表可能有不同的程序来做处理。

I used the same link Parallelizing calls in PL/SQL

在 PL/SQL 中使用了相同的链接 并行调用

As a solution I have created multiple dbms_schedulerjobs which will be called at the same time. All these jobs (JOB1, JOB2--- - -JOB10) will have the same procedure (ProcForAll_Processing) as JOB_ACTIONto achieve parallel processing.

作为解决方案,我创建了多个dbms_scheduler将同时调用的作业。所有这些作业 ( JOB1, JOB2--- - -JOB10) 将具有相同的过程 ( ProcForAll_Processing)JOB_ACTION以实现并行处理。

begin
    dbms_scheduler.run_job('JOB1',false);
    dbms_scheduler.run_job('JOB2',false);
  end; 

ProcForAll_Processing: This procedure in turn will call 6 other procedures Proc1,proc2,proc3 --- -- - -- - Proc6in sequential manner. I want to achieve parallel processing for these as well.

ProcForAll_Processing: 这个程序会依次调用其他6个程序 Proc1,proc2,proc3 --- -- - -- - Proc6。我也想为这些实现并行处理。

P.S: We can't create further jobs to achieve parallel processing in ProcForAll_Processingproc as it may lead to consume further resources and also DBA is not agreeing for creating further jobs. Also, I can't use dbms_parallel_executefor parallel processing.

PS:我们不能创建更多的工作来实现ProcForAll_Processingproc 中的并行处理,因为它可能会导致消耗更多的资源,而且 DBA 也不同意创建更多的工作。另外,我不能 dbms_parallel_execute用于并行处理。

Please help me as I am really stuck to get it done

请帮助我,因为我真的很难完成它

回答by Ilia Maskov

It is impossible in general case without jobs, and it will make multiple sessions for this. There is no such thing as multithreading PL\SQLwith a few exceptions. One of them is parallel execution of sqlstatements [1]. So there are some attempts to abusethis stuff for parallel execution of PL\SQL code, for example try to look here [2].

在一般情况下没有工作是不可能的,它会为此进行多个会话。除了PL\SQL少数例外,没有多线程这样的东西。其中之一是sql语句的并行执行[1]。所以有一些尝试滥用这些东西来并行执行 PL\SQL 代码,例如尝试查看这里 [2]。

But as i've said it's abuseIMHO.

但正如我所说,恕我直言,这是滥用职权

Reference:

参考:

  1. https://docs.oracle.com/cd/B19306_01/server.102/b14223/usingpe.htm
  2. http://www.williamrobertson.net/documents/parallel-plsql-launcher.html
  1. https://docs.oracle.com/cd/B19306_01/server.102/b14223/usingpe.htm
  2. http://www.williamrobertson.net/documents/parallel-plsql-launcher.html

回答by Jon Heller

Get a new DBA. Or even better, cut them out of any decision making processes. A DBA should not review your code and should not tell you to not create jobs, unless there is a good, specific reason.

获得一个新的 DBA。或者甚至更好,将它们从任何决策过程中剔除。DBA 不应您的代码,也不应告诉您不要创建工作,除非有充分的、具体的原因。

Using DBMS_SCHEDULER to run things in parallel is by far the easiest and most common way to achieve this result. Of courseit's going to consume more resources, that's what parallelism will inevitably do.

到目前为止,使用 DBMS_SCHEDULER 并行运行事物是实现此结果的最简单和最常见的方法。 当然,它会消耗更多的资源,这就是并行性不可避免地要做的事情。

Another, poorer option, is to use parallel pipelined table functions. It's an advanced PL/SQL feature that can't be easily explained in a simple example. The best I can do is refer you to the manual.

另一个较差的选择是使用并行流水线表函数。这是一项高级 PL/SQL 功能,无法通过简单示例轻松解释。我能做的最好的事情就是让你参考手册