当前位置:网站首页>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
边栏推荐
- 1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效
- Dall-E Mini的Mega版本模型发布,已开放下载
- [paper reading | deep reading] rolne: improving the quality of network embedding with structural role proximity
- The GPG keys listed for the "MySQL 8.0 community server" repository are already ins
- 【论文阅读|深读】RolNE: Improving the Quality of Network Embedding with Structural Role Proximity
- 纽约大学 CITIES 研究中心招聘理学硕士和博士后
- 【LeetCode】Day97-移除链表元素
- 处理streamlit库上传的图片文件
- [paper reading | deep reading] graphsage:inductive representation learning on large graphs
- Integrated navigation: product description and interface description of zhonghaida inav2
猜你喜欢

Infrared camera: juge infrared mag32 product introduction

【森城市】GIS数据漫谈(二)

新一代云原生消息队列(一)

Cat recycling bin

Collection recommandée!! Quel plug - in de gestion d'état flutter est le plus fort? Regardez le classement des manons de l'île, s'il vous plaît!

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

The mega version model of dall-e MINI has been released and is open for download

传感器:土壤湿度传感器(XH-M214)介绍及stm32驱动代码

Robot team learning method to achieve 8.8 times human return

Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
随机推荐
#夏日挑战赛#数据库学霸笔记(下)~
Dall-E Mini的Mega版本模型发布,已开放下载
XML to map tool class xmlmaputils (tool class V)
[C # notes] reading and writing of the contents of text files
Alibaba cloud middleware open source past
Processing image files uploaded by streamlit Library
go swagger使用
企业中台建设新路径——低代码平台
STM32项目 -- 选题分享(部分)
阿里云易立:云原生如何破解企业降本提效难题?
MetaForce原力元宇宙开发搭建丨佛萨奇2.0系统开发
FLIR blackfly s industrial camera: explanation and configuration of color correction and code setting method
Introduction to microservice architecture
一片葉子兩三萬?植物消費爆火背後的“陽謀”
2022 system integration project management engineer examination knowledge point: Mobile Internet
[paper reading | deep reading] dngr:deep neural networks for learning graph representations
Draco - glTF模型压缩利器
MySQL execution process and sequence
New generation cloud native message queue (I)
新一代云原生消息队列(一)