当前位置:网站首页>Opengauss kernel: simple query execution
Opengauss kernel: simple query execution
2022-06-24 23:53:00 【Huawei cloud developer Alliance】
Abstract : This paper mainly analyzes the application of simple query statements in business processing threads Postgres Execution process on , And how to use gdb Sort out the logic of the code .
This article is shared from Huawei cloud community 《openGauss Kernel analysis ( Two ): Simple query execution 》, author :Gauss Squirrel Club .
Simple query execution
SQL The engine is the portal to the database system , The entry function to execute the user's simple query is exec_simple_query. Running on the business processing thread Postgres.
You can usually SQL The engine is divided into SQL Parsing and query optimization are two main modules ,SQL Engine response to input SQL Lexical analysis of language 、 Syntax analysis 、 Semantic analysis , To generate a logical execution plan , After algebraic optimization and cost optimization, the logical execution plan , Generate physical execution plan .
stay SQL After the engine optimizes the user's query parsing into an executable plan , The database enters the query execution phase . The actuator extracts relevant data based on the execution plan 、 operation 、 to update 、 Delete and other operations , In order to achieve the purpose of user query .

exec_simple_query

1.start_xact_command(): Start a transaction
2.pg_parse_query(): Lexical and grammatical analysis of query statements , Generate one or more initial parsing trees
3. Get into foreach (parsetree_item, parsetree_list) loop , Execute a query on each parse tree
4. pg_**yze_and_rewrite(): Based on the syntax analysis tree, generate Query Logical query tree of data structure , And perform operations such as rewriting
5. pg_plan_queries(): Optimize the logical query tree , Generate query plan
6. CreatePortal(): establish Portal, Portal Is to perform SQL The carrier of sentence , Every one of them SQL Corresponding to the only Portal
7. PortalStart(): Responsible for Portal Structure initialization , Including operator initialization 、 Memory context allocation, etc
8. PortalRun(): Responsible for real execution and computation , It is the core of the actuator
9. PortalDrop(): Responsible for the final clean-up , Mainly data structure 、 Cache cleanup
10. finish_xact_command(): Complete transaction commit
11. EndCommand(): Notify the client that the query execution is complete
gdb debugging
Debugging requires symbol information ,configure Use the following command
./configure --gcc-version=7.3.0 CC=g++ CFLAGS='-O0' --prefix=$GAUSSHOME --3rd=$BINARYLIBS --enable-debug --enable-cassert --enable-thread-safety --with-readline --without-zlibgdb attach Process number , The process number here is 17012
gdb attach 17012info threads See all threads ,t Thread number switch thread ,bt You can view the thread call stack

You can also use linux Tools gstack Print function call stack

To debug select Statements, for example ,gdb attach Process number , stay exec_simple_query Set a breakpoint , perform select Statement to start debugging



Click to follow , The first time to learn about Huawei's new cloud technology ~
边栏推荐
猜你喜欢

Why do more and more physical stores use VR panorama? What are the advantages?

JPA学习2 - 核心注解、注解进行增删改查、List查询结果返回类型、一对多、多对一、多对多

How does VR panorama make money? Based on the objective analysis of the market from two aspects

Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference

Volcano成Spark默认batch调度器

svg+js键盘控制路径

信号完整性(SI)电源完整性(PI)学习笔记(二十五)差分对与差分阻抗(五)

How to use stm32subeide SWV function

js监听页面或元素scroll事件,滚动到底部或顶部

美国众议院议员:数字美元将支持美元作为全球储备货币
随机推荐
VR全景制作的优势是什么?为什么能得到青睐?
Hello C (IV) -- pointer and function
今天睡眠质量记录79分
中低速航空航天电子总线概述
中学校园IP网络广播系统解决方案-校园数字IP广播系统方案设计指南
Nominal resistance table of patch resistors with 5% and 1% accuracy
go 语言指针,值引用和指针引用
Tiktok practice ~ project associated unicloud
Scala IO serialization and deserialization
Hibernate学习3 - 自定义SQL
抖音实战~实现App端视频上传与发布
Number of bytes corresponding to common data types
Solution of IP network broadcasting system in Middle School Campus - Design Guide for Campus Digital IP broadcasting system
Hyperledger Fabric 2. X dynamic update smart contract
2021-2022 China's financial digitalization "new" insight Industry Research Report
Fast pace? high pressure? VR panoramic Inn brings you a comfortable life
Volcano成Spark默认batch调度器
svg线条动画背景js特效
First person singular reading notes
7-9 treasure hunt route