PART4DATASTORAGEANDQUERYChapter13QueryProcessingMarch2009DatabaseSystemConcepts-Chapter13QueryProcessing-3IntroductionQueryoneormoreoperationsonadatabase,orrequestsforDBaccessahigh-leveldatabaselanguage(e.g.SQL,QUEL,declarative,API)statement,orasequenceofstatementsQueryprocessing(P531)(DBMS’)activitiesinvolvedinextractingdatafromadatabase,includingparsingandtranslation,queryoptimization,andevaluation(执行)Programscompilingandexecutingvs.QueryprocessingrefertoFig.13.0.1C,Pascalprograms词法/语法/语义分析中间代码生成(中间)代码优化目标代码生成程序编译/编译程序执/OS进程管理&进程调度并发控制死锁处理query扫描和语法/语义分析查询优化(优化后)查询执行计划查询代码生成Queryprocessing/DBMSprocess/thread事务处理/DBMSChapter.13,14Chapter.15,16,17transaction关系代数表达式&查询树查询计划执行的代码事务管理目标程序代码(§14)&事务调度并发控制死锁处理恢复技术(§13)(§15)(§16)(§17)Fig.13.0.1March2009DatabaseSystemConcepts-Chapter13QueryProcessing-5Basicstepsinqueryprocessing,§13.1Measuresofquerycost,§13.2performanceindicesforqueryoptimizationEvaluatingofexecutionplan,i.e.executingofquerycodeevaluatingofindividualrelationalalgebraoperations,§13.3-§13.6evaluatingofexpression,i.e.asequenceofrelationalalgebraoperations,§13.7ThreepartsChapter13March2009DatabaseSystemConcepts-Chapter13QueryProcessing-6StepsinqueryprocessingFig.13.1§13.1OverviewDatabaseSystemDBfileDBMSFig.13.1Stepsinqueryprocessingmetadataindatadictionarye.g.selectUsersMarch2009DatabaseSystemConcepts-Chapter13QueryProcessing-8Step1.Parsingandtranslationtranslatethequeryintoaparser-treerepresentationparsercheckssyntax,verifiesthecorrectnessoftherelationsinthequeryparseralsoreplacestheviewinthequerywiththerelationsonwhichthisviewisbuiltontheparser-treeisthentranslatedintorelationalalgebraexpression§13.1Overview(cont.)March2009DatabaseSystemConcepts-Chapter13QueryProcessing-9Step2.QueryOptimizationamongstallequivalentqueryevaluationplans,choosetheonewithlowestcostthecosti...