PostgreSQL中PlannedStmt的跟踪分析
这篇文章主要为大家展示了“PostgreSQL中PlannedStmt的跟踪分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“PostgreSQL中PlannedStmt的跟踪分析”这篇文章吧。
计划树
二、数据结构Plan
/*----------------*Plannode**Allplannodes"derive"fromthePlanstructurebyhavingthe*Planstructureasthefirstfield.Thisensuresthateverythingworks*whennodesarecasttoPlan's.(nodepointersarefrequentlycasttoPlan**whenpassedaroundgenericallyintheexecutor)**WeneveractuallyinstantiateanyPlannodes;thisisjustthecommon*abstractsuperclassforallPlan-typenodes.*----------------*/typedefstructPlan{NodeTagtype;/**estimatedexecutioncostsforplan(seecostsize.cformoreinfo)*/Coststartup_cost;/*costexpendedbeforefetchinganytuples*/Costtotal_cost;/*totalcost(assumingalltuplesfetched)*//**planner'sestimateofresultsizeofthisplanstep*/doubleplan_rows;/*numberofrowsplanisexpectedtoemit*/intplan_width;/*averagerowwidthinbytes*//**informationneededforparallelquery*/boolparallel_aware;/*engageparallel-awarelogic?*/boolparallel_safe;/*OKtouseaspartofparallelplan?*//**CommonstructuraldataforallPlantypes.*/intplan_node_id;/*uniqueacrossentirefinalplantree*/List*targetlist;/*targetlisttobecomputedatthisnode*/List*qual;/*implicitly-ANDedqualconditions*/structPlan*lefttree;/*inputplantree(s)*/structPlan*righttree;List*initPlan;/*InitPlannodes(un-correlatedexpr*subselects)*//**Informationformanagementofparameter-change-drivenrescanning**extParamincludestheparamIDsofallexternalPARAM_EXECparams*affectingthisplannodeoritschildren.setParamparamsfromthe*node'sinitPlansarenotincluded,buttheirextParamsare.**allParamincludesalltheextParamparamIDs,plustheIDsoflocal*paramsthataffectthenode(i.e.,thesetParamsofitsinitplans).*Theseare_all_thePARAM_EXECparamsthataffectthisnode.*/Bitmapset*extParam;Bitmapset*allParam;}Plan;
Limit
/*----------------*limitnode**Note:asofPostgres8.2,theoffsetandcountexpressionsareexpected*toyieldint8,ratherthanint4asbefore.*----------------*/typedefstructLimit{Planplan;Node*limitOffset;/*OFFSETparameter,orNULLifnone*/Node*limitCount;/*COUNTparameter,orNULLifnone*/}Limit;
Sort
/*----------------*sortnode*----------------*/typedefstructSort{Planplan;intnumCols;/*numberofsort-keycolumns*/AttrNumber*sortColIdx;/*theirindexesinthetargetlist*/Oid*sortOperators;/*OIDsofoperatorstosortthemby*/Oid*collations;/*OIDsofcollations*/bool*nullsFirst;/*NULLSFIRST/LASTdirections*/}Sort;
Append
/*----------------*Appendnode-*Generatetheconcatenationoftheresultsofsub-plans.*----------------*/typedefstructAppend{Planplan;List*appendplans;/**All'appendplans'precedingthisindexarenon-partialplans.All*'appendplans'fromthisindexonwardsarepartialplans.*/intfirst_partial_plan;/*RTindexesofnon-leaftablesinapartitiontree*/List*partitioned_rels;/*Infoforrun-timesubplanpruning;NULLifwe'renotdoingthat*/structPartitionPruneInfo*part_prune_info;}Append;
NestLoop
/*----------------*nestloopjoinnode**ThenestParamslistidentifiesanyexecutorParamsthatmustbepassed*intoexecutionoftheinnersubplancarryingvaluesfromthecurrentrow*oftheoutersubplan.Currentlywerestrictthesevaluestobesimple*Vars,butperhapssomedaythat'dbeworthrelaxing.(Note:duringplan*creation,theparamvalcanactuallybeaPlaceHolderVarexpression;butit*mustbeaVarwithvarnoOUTER_VARbythetimeitgetstotheexecutor.)*----------------*/typedefstructNestLoop{Joinjoin;List*nestParams;/*listofNestLoopParamnodes*/}NestLoop;typedefstructNestLoopParam{NodeTagtype;intparamno;/*numberofthePARAM_EXECParamtoset*/Var*paramval;/*outer-relationVartoassigntoParam*/}NestLoopParam;/**==========*Joinnodes*==========*//*----------------*mergejoinnode**Theexpectedorderingofeachmergeablecolumnisdescribedbyabtree*opfamilyOID,acollationOID,adirection(BTLessStrategyNumberor*BTGreaterStrategyNumber)andanulls-firstflag.Notethatthetwosides*ofeachmergeclausemaybeofdifferentdatatypes,buttheyareorderedthe*samewayaccordingtothecommonopfamilyandcollation.Theoperatorin*eachmergeclausemustbeanequalityoperatoroftheindicatedopfamily.*----------------*/typedefstructMergeJoin{Joinjoin;boolskip_mark_restore;/*Canweskipmark/restorecalls?*/List*mergeclauses;/*mergeclausesasexpressiontrees*//*thesearearrays,buthavethesamelengthasthemergeclauseslist:*/Oid*mergeFamilies;/*per-clauseOIDsofbtreeopfamilies*/Oid*mergeCollations;/*per-clauseOIDsofcollations*/int*mergeStrategies;/*per-clauseordering(ASCorDESC)*/bool*mergeNullsFirst;/*per-clausenullsordering*/}MergeJoin;/*----------------*hashjoinnode*----------------*/typedefstructHashJoin{Joinjoin;List*hashclauses;}HashJoin;/*----------------*Joinnode**jointype:ruleforjoiningtuplesfromleftandrightsubtrees*inner_uniqueeachoutertuplecanmatchtonomorethanoneinnertuple*joinqual:qualconditionsthatcamefromJOIN/ONorJOIN/USING*(plan.qualcontainsconditionsthatcamefromWHERE)**WhenjointypeisINNER,joinqualandplan.qualaresemantically*interchangeable.ForOUTERjointypes,thetwoare*not*interchangeable;*onlyjoinqualisusedtodeterminewhetheramatchhasbeenfoundfor*thepurposeofdecidingwhethertogeneratenull-extendedtuples.*(Butplan.qualisstillappliedbeforeactuallyreturningatuple.)*Foranouterjoin,onlyjoinqualsareallowedtobeusedasthemerge*orhashconditionofamergeorhashjoin.**inner_uniqueissetifthejoinqualsaresuchthatnomorethanoneinner*tuplecouldmatchanygivenoutertuple.Thisallowstheexecutorto*skipsearchingforadditionalmatches.(Thismustbeprovablefromjust*thejoinquals,ignoringplan.qual,duetowheretheexecutortestsit.)*----------------*/typedefstructJoin{Planplan;JoinTypejointype;boolinner_unique;List*joinqual;/*JOINquals(inadditiontoplan.qual)*/}Join;
SeqScan
/**==========*Scannodes*==========*/typedefstructScan{Planplan;Indexscanrelid;/*relidisindexintotherangetable*/}Scan;/*----------------*sequentialscannode*----------------*/typedefScanSeqScan;
以上是“PostgreSQL中PlannedStmt的跟踪分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。