当前位置:网站首页>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
边栏推荐
- #yyds干货盘点# 解决名企真题:最大差值
- postgresql之整体查询大致过程
- New generation cloud native message queue (I)
- Introduction to FLIR blackfly s industrial camera
- Stm32f4 --- PWM output
- 传感器:DS1302时钟芯片及驱动代码
- 一片葉子兩三萬?植物消費爆火背後的“陽謀”
- 猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
- Centos8 install MySQL 8.0 using yum x
- Stm32f4 --- general timer update interrupt
猜你喜欢
ROS learning (XIX) robot slam function package cartographer
Integrated navigation: product description and interface description of zhonghaida inav2
[paper reading | deep reading] rolne: improving the quality of network embedding with structural role proximity
云原生混部最后一道防线:节点水位线设计
Infrared camera: juge infrared mag32 product introduction
3D激光SLAM:Livox激光雷达硬件时间同步
Schedulx v1.4.0 and SaaS versions are released, and you can experience the advanced functions of cost reduction and efficiency increase for free!
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
How can reinforcement learning be used in medical imaging? A review of Emory University's latest "reinforcement learning medical image analysis", which expounds the latest RL medical image analysis co
postgresql之integerset
随机推荐
云原生混部最后一道防线:节点水位线设计
【论文阅读|深读】RolNE: Improving the Quality of Network Embedding with Structural Role Proximity
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
argo workflows源码解析
3D laser slam: time synchronization of livox lidar hardware
企业中台建设新路径——低代码平台
[C # notes] use file stream to copy files
FLIR blackfly s usb3 industrial camera: how to use counters and timers
豆瓣平均 9.x,分布式领域的 5 本神书!
XML to map tool class xmlmaputils (tool class V)
FLIR blackfly s industrial camera: synchronous shooting of multiple cameras through external trigger
MySQL execution process and sequence
FLIR blackfly s industrial camera: configure multiple cameras for synchronous shooting
【论文阅读|深读】DNGR:Deep Neural Networks for Learning Graph Representations
【服务器数据恢复】raid损坏导致戴尔某型号服务器崩溃的数据恢复案例
What to do when encountering slow SQL? (next)
Errors made in the development of merging the quantity of data in the set according to attributes
FLIR blackfly s usb3 industrial camera: white balance setting method
TiFlash 源码阅读(四)TiFlash DDL 模块设计及实现分析
PostgreSQL图形化界面工具之pgAdmin4