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

哪些場景可以使用并行度
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ì)劃中就會多出一列:in-out。相關(guān)視圖為:v$pq_sysstat、v$pq_tqstat


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

表打開并行的方法
alter table sales parallel;
alter table sales parallel 8;

hint開啟表查詢的并行度
select /*+ parallel(tablename,8) */ * from tablename
select /*+ parallel(sales,8) */ * from sales

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


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

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



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

比如80個CPU、現(xiàn)在已經(jīng)使用了60個,剩下20個(PARALLEL_SERVERS_TARGET),現(xiàn)在來了一個60個并行度的查詢,怎么辦?
如果PARALLEL_MIN_PERCENT=10,就是10%可以用,就是最少使用60*10%=6個并行度,6<20,可以使用
如果PARALLEL_MIN_PERCENT=50,就是使用60*50%=30,30>20,如果PARALLEL_DEGREE_POLICY=MANUAL,則不夠,直接報(bào)錯,如果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語句的并行服務(wù)器進(jìn)程可以在群集中的任何或所有Oracle RAC節(jié)點(diǎn)上運(yùn)行。通過將PARALLEL_FORCE_LOCAL設(shè)置為true,并行服務(wù)器進(jìn)程受到限制,因此它們只能在查詢協(xié)調(diào)程序所在的同一個Oracle RAC節(jié)點(diǎn)(執(zhí)行SQL語句的節(jié)點(diǎn))上運(yùn)行
默認(rèn)FORCE,就是可以使用其他節(jié)點(diǎn)的CPU,并不是說在其他節(jié)點(diǎn)執(zhí)行SQL,執(zhí)行SQL還是本節(jié)點(diǎn)(即PX在本節(jié)點(diǎn)),但是可以使用其他節(jié)點(diǎn)的資源做coordinator process即QC(就是管理下面這些并行度的一個進(jìn)程,一個個的并行程序叫parallel execution servers即PX),此參數(shù)最好設(shè)置為TRUE

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ù)庫將實(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í)例啟動時由Oracle創(chuàng)建的并行執(zhí)行進(jìn)程的數(shù)量
PARALLEL_MIN_SERVERS默認(rèn)是0,如果修改為5,說明就算是空閑不用,也開啟5個進(jìn)程,相關(guān)視圖v$px_process
比如一開機(jī)就有ora_p001_sid、ora_p002_sid、ora_p003_sid、ora_p004_sid、ora_p004_sid這樣5個進(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指定是否啟用并行度,語句排隊(duì)和內(nèi)存中并行執(zhí)行的自動程度

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ù)量百分比。 并行語句隊(duì)列未啟用時(PARALLEL_DEGREE_POLICY設(shè)置為manual or limited),此參數(shù)控制并行操作的行為。它確保操作始終獲得并行執(zhí)行服務(wù)器的最小百分比或出錯。設(shè)置此參數(shù)可確保并行操作不會執(zhí)行,除非提供足夠的資源。默認(rèn)值0意味著沒有設(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指定在使用語句排隊(duì)之前允許運(yùn)行并行語句的并行服務(wù)器進(jìn)程的數(shù)量。當(dāng)參數(shù)PARALLEL_DEGREE_POLICY設(shè)置為AUTO時,如果必需的并行服務(wù)器進(jìn)程不可用,Oracle將對需要并行執(zhí)行的SQL語句進(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īng)該具有的最短執(zhí)行時間。默認(rèn)情況下,它被設(shè)置為10秒。自動并行度僅在PARALLEL_DEGREE_POLICY設(shè)置為AUTO或LIMITED時才能使用。

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時,啟用一個自適應(yīng)算法,旨在提高使用并行執(zhí)行的多用戶環(huán)境的性能。該算法根據(jù)查詢啟動時的系統(tǒng)負(fù)載自動降低請求的并行度。并行度的有效程度是基于默認(rèn)的并行度,或者從表或者提示的程度除以還原因子

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

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

廣告

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

微信小程序開發(fā)