parallel并行度的相關(guān)操作、概念、參數(shù)解釋

哪些場(chǎng)景可以使用并行度
table scan、fast full index scans、partition index range scans(僅限local索引)
create table as、create index、rebuild index、move、split、DML(insert\update\delete)

當(dāng)使用了并行執(zhí)行,SQL的執(zhí)行計(jì)劃中就會(huì)多出一列:in-out。相關(guān)視圖為:v$pq_sysstat、v$pq_tqstat


alter session force parallel query parallel N  --強(qiáng)制使用N個(gè)并行度,force parallel會(huì)覆蓋默認(rèn)的parallel設(shè)置
alter session enable parallel query  --使用默認(rèn)的并行度數(shù)量

表打開(kāi)并行的方法
alter table sales parallel;
alter table sales parallel 8;

hint開(kāi)啟表查詢(xún)的并行度
select /*+ parallel(tablename,8) */ * from tablename
select /*+ parallel(sales,8) */ * from sales

DML使用hint開(kāi)啟并行時(shí),表必須打開(kāi)并行,因?yàn)閡pdate時(shí),是要先查出表的數(shù)據(jù)即先執(zhí)行select,所以u(píng)pdate開(kāi)啟了并行度,select也要開(kāi)啟并行度,否則只有update是并行,但select卻不是。


并行度GRANULES
1.并行工作的一個(gè)基本單元被稱(chēng)為GRANULES
2,一個(gè)GRANULES只能有一個(gè)并行執(zhí)行的server進(jìn)行讀的操作
3,并行的一個(gè)server可以從一個(gè)GRANULES到另外一個(gè)GRANULES的執(zhí)行任務(wù),即當(dāng)一個(gè)任務(wù)完成了就去接著執(zhí)行下一個(gè)任務(wù)。

并行度GRANULES分兩種
1.block range granules(自動(dòng)根據(jù)塊的數(shù)目范圍為分)
Block range granules: Server進(jìn)程在執(zhí)行的時(shí)候就動(dòng)態(tài)的產(chǎn)生。
2.partition granules(用于分區(qū)表,比如有8個(gè)分區(qū),它可能會(huì)分四個(gè)并行度,這樣四個(gè)并行度可能在四個(gè)不同分區(qū)上)
Partition granules : 有分區(qū)的數(shù)量靜態(tài)的決定。



三個(gè)著名參數(shù)的應(yīng)用場(chǎng)景
PARALLEL_DEGREE_POLICY
PARALLEL_MIN_PERCENT
PARALLEL_SERVERS_TARGET

比如80個(gè)CPU、現(xiàn)在已經(jīng)使用了60個(gè),剩下20個(gè)(PARALLEL_SERVERS_TARGET),現(xiàn)在來(lái)了一個(gè)60個(gè)并行度的查詢(xún),怎么辦?
如果PARALLEL_MIN_PERCENT=10,就是10%可以用,就是最少使用60*10%=6個(gè)并行度,6<20,可以使用
如果PARALLEL_MIN_PERCENT=50,就是使用60*50%=30,30>20,如果PARALLEL_DEGREE_POLICY=MANUAL,則不夠,直接報(bào)錯(cuò),如果PARALLEL_DEGREE_POLICY=AUTO,則進(jìn)入隊(duì)列。


PARALLEL_FORCE_LOCALcontrols parallel execution in an Oracle RAC environment. By default, the parallel server processes selected to execute a SQL statement can operate on any or all Oracle RAC nodes in the cluster. By setting PARALLEL_FORCE_LOCAL to true, the parallel server processes are restricted so that they can only operate on the same Oracle RAC node where the query coordinator resides (the node on which the SQL statement was executed on).
控制Oracle RAC環(huán)境中的并行執(zhí)行。默認(rèn)情況下,選擇執(zhí)行SQL語(yǔ)句的并行服務(wù)器進(jìn)程可以在群集中的任何或所有Oracle RAC節(jié)點(diǎn)上運(yùn)行。通過(guò)將PARALLEL_FORCE_LOCAL設(shè)置為true,并行服務(wù)器進(jìn)程受到限制,因此它們只能在查詢(xún)協(xié)調(diào)程序所在的同一個(gè)Oracle RAC節(jié)點(diǎn)(執(zhí)行SQL語(yǔ)句的節(jié)點(diǎn))上運(yùn)行
默認(rèn)FORCE,就是可以使用其他節(jié)點(diǎn)的CPU,并不是說(shuō)在其他節(jié)點(diǎn)執(zhí)行SQL,執(zhí)行SQL還是本節(jié)點(diǎn)(即PX在本節(jié)點(diǎn)),但是可以使用其他節(jié)點(diǎn)的資源做coordinator process即QC(就是管理下面這些并行度的一個(gè)進(jìn)程,一個(gè)個(gè)的并行程序叫parallel execution servers即PX),此參數(shù)最好設(shè)置為T(mén)RUE

PARALLEL_MAX_SERVERSspecifies the maximum number of parallel execution processes and parallel recovery processes for an instance. As demand increases, Oracle Database increases the number of processes from the number created at instance startup up to this value
PARALLEL_MAX_SERVERS指定實(shí)例的并行執(zhí)行進(jìn)程和并行恢復(fù)進(jìn)程的最大數(shù)量。隨著需求的增加,Oracle數(shù)據(jù)庫(kù)將實(shí)例啟動(dòng)時(shí)創(chuàng)建的進(jìn)程數(shù)量增加到此值

PARALLEL_MIN_SERVERSspecifies the minimum number of parallel execution processes for the instance. This value is the number of parallel execution processes Oracle creates when the instance is started
PARALLEL_MIN_SERVERS指定實(shí)例的最小并行執(zhí)行進(jìn)程數(shù)。 該值是在實(shí)例啟動(dòng)時(shí)由Oracle創(chuàng)建的并行執(zhí)行進(jìn)程的數(shù)量
PARALLEL_MIN_SERVERS默認(rèn)是0,如果修改為5,說(shuō)明就算是空閑不用,也開(kāi)啟5個(gè)進(jìn)程,相關(guān)視圖v$px_process
比如一開(kāi)機(jī)就有ora_p001_sid、ora_p002_sid、ora_p003_sid、ora_p004_sid、ora_p004_sid這樣5個(gè)進(jìn)程,這就是partition slave process they do parallel dml ddl and query jobs..

PARALLEL_DEGREE_POLICYspecifies whether or not automatic degree of Parallelism,statement queuing, and in-memory parallel execution will be enabled
PARALLEL_DEGREE_POLICY指定是否啟用并行度,語(yǔ)句排隊(duì)和內(nèi)存中并行執(zhí)行的自動(dòng)程度

PARALLEL_MIN_PERCENTlets you specify the minimum percentage of the requested number of parallel execution processes required for parallel execution. This parameter controls the behavior for parallel operations when parallel statement queuing is not enabled (when PARALLEL_DEGREE_POLICY is set to manual or limited). It ensures that an operation always gets a minimum percentage of parallel execution servers or errors out. Setting this parameter ensures that parallel operations will not execute unless adequate resources are available. The default value of 0 means that no minimum percentage of processes has been set.
If 8 of the 10 parallel execution processes are busy, only 2 processes are available. If you then request a query with a degree of parallelism of 8, the minimum 50% will not be met.
PARALLEL_MIN_PERCENT可以指定并行執(zhí)行所需的并行執(zhí)行進(jìn)程的最小數(shù)量百分比。 并行語(yǔ)句隊(duì)列未啟用時(shí)(PARALLEL_DEGREE_POLICY設(shè)置為manual or limited),此參數(shù)控制并行操作的行為。它確保操作始終獲得并行執(zhí)行服務(wù)器的最小百分比或出錯(cuò)。設(shè)置此參數(shù)可確保并行操作不會(huì)執(zhí)行,除非提供足夠的資源。默認(rèn)值0意味著沒(méi)有設(shè)置最小進(jìn)程百分比。

PARALLEL_SERVERS_TARGETspecifies the number of parallel server processes allowed to run parallel statements before statement queuing will be used. When the parameter PARALLEL_DEGREE_POLICY is set to AUTO, Oracle will queue SQL statements that require parallel execution, if the necessary parallel server processes are not available.
PARALLEL_SERVERS_TARGE指定在使用語(yǔ)句排隊(duì)之前允許運(yùn)行并行語(yǔ)句的并行服務(wù)器進(jìn)程的數(shù)量。當(dāng)參數(shù)PARALLEL_DEGREE_POLICY設(shè)置為AUTO時(shí),如果必需的并行服務(wù)器進(jìn)程不可用,Oracle將對(duì)需要并行執(zhí)行的SQL語(yǔ)句進(jìn)行排隊(duì)。

PARALLEL_MIN_TIME_THRESHOLDspecifies the minimum execution time a statement should have before the statement is considered for automatic degree of parallelism. By default, this is set to 10 seconds. Automatic degree of parallelism is only enabled if PARALLEL_DEGREE_POLICY is set to AUTO or LIMITED.
PARALLEL_MIN_TIME_THRESHOLD指定語(yǔ)句在考慮自動(dòng)并行度之前語(yǔ)句應(yīng)該具有的最短執(zhí)行時(shí)間。默認(rèn)情況下,它被設(shè)置為10秒。自動(dòng)并行度僅在PARALLEL_DEGREE_POLICY設(shè)置為AUTO或LIMITED時(shí)才能使用。

PARALLEL_ADAPTIVE_MULTI_USER, when set to true, enables an adaptive algorithm designed to improve performance in multiuser environments that use parallel execution. The algorithm automatically reduces the requested degree of parallelism based on the system load at query startup time. The effective degree of parallelism is based on the default degree of parallelism, or the degree from the table or hints, divided by a reduction facto
PARALLEL_ADAPTIVE_MULTI_USER,當(dāng)設(shè)置為true時(shí),啟用一個(gè)自適應(yīng)算法,旨在提高使用并行執(zhí)行的多用戶(hù)環(huán)境的性能。該算法根據(jù)查詢(xún)啟動(dòng)時(shí)的系統(tǒng)負(fù)載自動(dòng)降低請(qǐng)求的并行度。并行度的有效程度是基于默認(rèn)的并行度,或者從表或者提示的程度除以還原因子

標(biāo)題名稱(chēng):parallel并行度的相關(guān)操作、概念、參數(shù)解釋
網(wǎng)頁(yè)網(wǎng)址:http://muchs.cn/article6/iiooog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、微信公眾號(hào)、面包屑導(dǎo)航、品牌網(wǎng)站設(shè)計(jì)、Google、自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開(kāi)發(fā)