当前位置:网站首页>Overall query process of PostgreSQL
Overall query process of PostgreSQL
2022-07-07 02:21:00 【happytree001】
Client pass pg The general process of server query is as follows

One 、 Establishing a connection
The client first needs to connect pg The server , After the server establishes a connection with the client fork A subprocess handles subsequent client requests , The server then waits for the next client to connect .
Two 、 Send a request
The client sends the request data to pg The server ,pg Subprocess read request .
- The client sends the request
Like the command line , Read user input , Send to the serversrc/bin/psql/mainloop.c
int
MainLoop(FILE *source)
{
...
SendQuery(query_buf->data);
...
}
- Server receives request
void
PostgresMain(int argc, char *argv[],
const char *dbname,
const char *username)
{
...
for (;;)
{
...
firstchar = ReadCommand(&input_message);
...
}
}
3、 ... and 、 analysis
Take a simple query as an example . The server receives a string , You need to parse and understand this data to execute .
src/backend/tcop/postgres.c
static void
exec_simple_query(const char *query_string)
{
...
parsetree_list = pg_parse_query(query_string);
...
}
Through lexical and grammatical analysis , Build a primitive syntax tree .
Four 、 Optimize
static void
exec_simple_query(const char *query_string)
{
...
querytree_list = pg_analyze_and_rewrite(parsetree, query_string,
NULL, 0, NULL);
plantree_list = pg_plan_queries(querytree_list, query_string,
CURSOR_OPT_PARALLEL_OK, NULL);
..
}
Transform the original syntax tree into a query tree , And optimize and rewrite the query tree , Improve execution speed .
5、 ... and 、 perform
static void
exec_simple_query(const char *query_string)
{
...
(void) PortalRun(portal,
FETCH_ALL,
true, /* always top level */
true,
receiver,
receiver,
&qc);
...
}
6、 ... and 、 Return results
The specific function is also found
边栏推荐
- 本周 火火火火 的开源项目!
- Processing image files uploaded by streamlit Library
- [paper reading | deep reading] dngr:deep neural networks for learning graph representations
- 3D激光SLAM:Livox激光雷达硬件时间同步
- The mega version model of dall-e MINI has been released and is open for download
- Date processing tool class dateutils (tool class 1)
- 纽约大学 CITIES 研究中心招聘理学硕士和博士后
- 老板被隔离了
- RC振荡器和晶体振荡器简介
- 【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
猜你喜欢

Lumion 11.0 software installation package download and installation tutorial

Flir Blackfly S USB3 工业相机:白平衡设置方法

Data connection mode in low code platform (Part 1)

Flir Blackfly S 工业相机:通过外部触发实现多摄像头同步拍摄

Correct use of BigDecimal

ROS learning (21) robot slam function package -- installation and testing of orbslam

Detailed explanation of line segment tree (including tested code implementation)

Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem

ROS learning (XX) robot slam function package -- installation and testing of rgbdslam

centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins
随机推荐
ROS learning (24) plugin
FLIR blackfly s industrial camera: auto exposure configuration and code
#yyds干货盘点# 解决名企真题:最大差值
Robot team learning method to achieve 8.8 times human return
Dall-E Mini的Mega版本模型发布,已开放下载
Flir Blackfly S USB3 工业相机:白平衡设置方法
Lumion 11.0 software installation package download and installation tutorial
将截断字符串或二进制数据
Redis configuration class redisconfig
Schedulx v1.4.0 and SaaS versions are released, and you can experience the advanced functions of cost reduction and efficiency increase for free!
The mega version model of dall-e MINI has been released and is open for download
MySQL execution process and sequence
Stm32f4 --- general timer update interrupt
Recent applet development records
String or binary data will be truncated
Flir Blackfly S 工业相机:自动曝光配置及代码
leetcode:5. 最长回文子串【dp + 抓着超时的尾巴】
RC振荡器和晶体振荡器简介
真实项目,用微信小程序开门编码实现(完结)
The boss is quarantined