当前位置:网站首页>Analysis of the execution process of opengauss simple query SQL
Analysis of the execution process of opengauss simple query SQL
2022-06-11 15:40:00 【Gauss squirrel Club】
Catalog
Last issue Cool guy analyzed openGauss Database startup process , Including the main thread , Starting process of auxiliary thread and business processing thread , This issue 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 .
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_analyze_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 work , 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 Clean-up
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



边栏推荐
- Idea2021.1 installation tutorial
- [creation mode] prototype mode
- [azure application service] nodejs express + msal realizes the authentication experiment of API Application token authentication (AAD oauth2 idtoken) -- passport authenticate()
- [creation mode] factory method mode
- openGauss简单查询SQL的执行流程解析
- Tangzhengrong: CTO is the intersection of business thinking and technical thinking
- Illustration of tiger international quarterly report: revenue of USD 52.63 million continued to be internationalized
- 【创建型模式】原型模式
- 【MongoDB】4. Usage specification of mongodb
- High number_ Chapter 6 infinite series__ Marklaurin series
猜你喜欢

Tencent interviewers share their interview experience, how to evaluate the interviewers' technical and personal comprehensive quality, and give you some suggestions on the interview
![[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle](/img/c7/ff28df36b8d5dda704aa829dd5264f.png)
[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle

Introduction and use of etcd

07 _ 行锁功过:怎么减少行锁对性能的影响?

What is excess product power? Find the secret key of the second generation cs75plus in the year of the tiger
![[azure application service] nodejs express + msal realizes the authentication experiment of API Application token authentication (AAD oauth2 idtoken) -- passport authenticate()](/img/11/7262211654680512dae0a9a696740e.png)
[azure application service] nodejs express + msal realizes the authentication experiment of API Application token authentication (AAD oauth2 idtoken) -- passport authenticate()

Oauth2的理解

Everything about JS functions
![[creation mode] builder mode](/img/8d/989c69772502a3ccda320025236e46.png)
[creation mode] builder mode

Hard core analysis lazy single case
随机推荐
Elk log analysis system
uniapp开发微信小程序,从构建到上线
Number system conversion (function)
中山大学大气院徐伟新教授团队关于弱对流造成极端降水的研究成果被Science亮点报道
Station B executives interpret the financial report: the epidemic has no impact on the company's long-term development, and the video trend is irresistible
04 _ In simple terms index (I)
Microservices - use of Nacos
企业开发如何写出优雅的二级分类【美团小案例】
Backtracking / solution space tree permutation tree
What is excess product power? Find the secret key of the second generation cs75plus in the year of the tiger
见微知著,细节上雕花:SVG生成矢量格式网站图标(Favicon)探究
微软韦青:狗尾巴的故事—数智时代的第一性原理 | 极客时间
Interview shock 26: how to stop threads correctly?
Oauth2的理解
JVM基础概念入门
openGauss简单查询SQL的执行流程解析
Recyclerview usage record
从0到1稳稳掌握大厂主流技术,年后涨薪不是必须的吗?
19. 二叉搜索树的插入删除修剪
[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle