当前位置:网站首页>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 ~
边栏推荐
- How does VR panorama make money? Based on the objective analysis of the market from two aspects
- go 语言指针,值引用和指针引用
- 明天就是PMP考试了(6月25日),这些大家都了解了吗?
- VR全景制作的优势是什么?为什么能得到青睐?
- Scala IO reads data from URLs and other data sources
- throttle-debounce.js:一个小型的防抖节流函数库
- 7-2 solving the stock buying problem
- Ethernet ARP Protocol
- One way 和two way ANOVA分析的区别是啥,以及如何使用SPSS或者prism进行统计分析
- Unveiling the secrets of the Winter Olympics | smartbi's partners supported the "front and back" of the Beijing Winter Olympics
猜你喜欢

抖音實戰~項目關聯UniCloud

Stm32f030f4 reading infrared remote control data

Hyperledger Fabric 2. X dynamic update smart contract

机器学习自学成才的十条戒律

DO280OpenShift访问控制--加密和ConfigMap

Solution of IP network broadcasting system in Middle School Campus - Design Guide for Campus Digital IP broadcasting system

单调栈以及单调栈的应用

Morris traverse

Morris遍历

canvas线条的动态效果
随机推荐
Annual salary of millions, 7 years of testing experience: stay at a fairly good track, accumulate slowly, wait for the wind to come
磁带svg动画js特效
Enterprise level ~uni app network request encapsulation
Hello C (VII) - structure
Morris traversal
QT cannot be edited with UTF-8
Why is it that the "Zhongtai" that was originally eaten by civil engineering is no longer fragrant?
Scala IO case
使用网络摄像头进行眼睛注视估计
第三代电力电子半导体:SiC MOSFET学习笔记(五)驱动电源调研
Tutorial details | how to edit and set the navigation function in the coolman system?
同济、阿里获CVPR最佳学生论文,李飞飞获黄煦涛奖,近6000人线下参会
基于三维GIS开发的水电工程建设方案
throttle-debounce. JS: a small anti shake throttling function library
走近Harvest Moon:Moonbeam DeFi狂欢会
Sitelock helps you with the top ten common website security risks
Unveiling the secrets of the Winter Olympics | smartbi's partners supported the "front and back" of the Beijing Winter Olympics
JPA学习1 - 概述、JPA、JPA核心注解、JPA核心对象
go 语言指针,值引用和指针引用
7-3 maximum sub segment and