当前位置:网站首页>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 ~
边栏推荐
- 年薪百万,7年测试经验:守在一个还算不错的赛道,慢慢积累,等风来
- 抖音实战~发布短视频流程梳理
- Sword finger offer merges two sorted lists
- throttle-debounce.js:一个小型的防抖节流函数库
- Hello C (IV) -- pointer and function
- 普通人的生活准则
- What are the advantages of VR panoramic production? Why is it favored?
- Assessment of public finance of Jilin University in March of the 22nd spring -00091
- 教程详解|在酷雷曼系统中如何编辑设置导览功能?
- Spark's wide dependence and narrow dependence yyds dry goods inventory
猜你喜欢

Laravel framework knowledge

ArcGIS loads free online historical images as the base map (no plug-ins are required)

教程详解|在酷雷曼系统中如何编辑设置导览功能?
Unveiling the secrets of the Winter Olympics | smartbi's partners supported the "front and back" of the Beijing Winter Olympics

Hello C (IV) -- pointer and function

Adding, deleting, querying and modifying MySQL tables

What are the advantages of VR panoramic production? Why is it favored?

Tape SVG animation JS effect

Ultra vires vulnerability & Logic vulnerability (hot) (VIII)

Hello C (I) -- basics of C language
随机推荐
信号完整性(SI)电源完整性(PI)学习笔记(二十五)差分对与差分阻抗(五)
7-2 construction of binary tree by post order + middle order sequence
Today's sleep quality record 79 points
Assessment of public finance of Jilin University in March of the 22nd spring -00091
Arbitrary file download of file operation vulnerability (7)
7-6 laying oil well pipeline
7-3 maximum sub segment and
抖音实战~实现App端视频上传与发布
Hello C (two) -- use of bit operation
VR全景制作的优势是什么?为什么能得到青睐?
First person singular reading notes
JPA学习2 - 核心注解、注解进行增删改查、List查询结果返回类型、一对多、多对一、多对多
抖音實戰~項目關聯UniCloud
基于三维GIS开发的水电工程建设方案
MySQL problem points
Window system installation Nacos
中学校园IP网络广播系统解决方案-校园数字IP广播系统方案设计指南
STM32CubeIDE SWV功能使用方法
Tutorial details | how to edit and set the navigation function in the coolman system?
svg+js键盘控制路径