当前位置:网站首页>Opengauss kernel: simple query execution
Opengauss kernel: simple query execution
2022-06-24 13:21: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 ~
边栏推荐
- I enlighten a friend and my personal understanding of the six patriarchs' Tan Jing
- 【概率论期末抱佛脚】概念+公式(不含参数估计)
- How to efficiently analyze online log
- Configure Yum proxy
- CVPR 2022 | 美團技術團隊精選論文解讀
- CVPR 2022 | interprétation de certains documents de l'équipe technique de meituan
- [2022 national tournament simulation] BigBen -- determinant, Du Jiao sieve
- Use abp Zero builds a third-party login module (I): Principles
- openGauss内核:简单查询的执行
- How does Argo family bucket make Devops easier?
猜你喜欢

Creation and use of unified links in Huawei applinking

几种常见的DoS攻击

openGauss内核:简单查询的执行

Teach you how to use airtestide to connect your mobile phone wirelessly!

A hero's note stirred up a thousand waves across 10 countries, and the first-line big factories sent people here- Gwei 2022 Singapore

1、贪吃蛇游戏设计

“我这个白痴,招到了一堆只会“谷歌”的程序员!”

LVGL库入门教程 - 颜色和图像

Opengauss kernel: simple query execution

一文讲透研发效能!您关心的问题都在
随机推荐
华为AppLinking中统一链接的创建和使用
How to create a new empty branch in the web development process of easyrtc?
What is SCRM? What is the difference between SCRM and CRM
Understanding openstack network
Reading notes of returning to hometown
DTU上报的数据值无法通过腾讯云规则引擎填入腾讯云数据库中
Cohere、OpenAI、AI21联合发布部署模型的最佳实践准则
Summary of the process of restoring damaged data in MySQL database
实现领域驱动设计 - 使用ABP框架 - 更新操作实体
16 safety suggestions from metamask project to solid programmers
CVPR 2022 | 美团技术团队精选论文解读
谁是鱼谁是饵?红队视角下蜜罐识别方式汇总
‘高并发&高性能&高可用服务程序’编写及运维指南
[data mining] final review (sample questions + a few knowledge points)
Open source monitoring system Prometheus
The agile way? Is agile development really out of date?
3. Caller 服务调用 - dapr
Optimization of MP4 file missing seconds caused by TS files when downloading videos from easydss video platform
Reset the password, and the automatic login of the website saved by chrome Google browser is lost. What is the underlying reason?
Comparator 排序函数式接口