当前位置:网站首页>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
边栏推荐
- [xlua notes] array of lua to array of C #
- Lumion 11.0 software installation package download and installation tutorial
- 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!
- FLIR blackfly s industrial camera: synchronous shooting of multiple cameras through external trigger
- 处理streamlit库上传的图片文件
- Blackfly S USB3工业相机:缓冲区处理
- Time synchronization of livox lidar hardware -- PPS method
- Command injection of cisp-pte
- Zabbix 5.0:通过LLD方式自动化监控阿里云RDS
- Unicode string converted to Chinese character decodeunicode utils (tool class II)
猜你喜欢
Flir Blackfly S 工业相机:自动曝光配置及代码
【服务器数据恢复】raid损坏导致戴尔某型号服务器崩溃的数据恢复案例
组合导航:中海达iNAV2产品描述及接口描述
leetcode:736. Lisp 语法解析【花里胡哨 + 栈 + 状态enumaotu + slots】
STM32F4---通用定时器更新中断
A new path for enterprise mid Platform Construction -- low code platform
使用Ceres进行slam必须要弄清楚的几个类和函数
SchedulX V1.4.0及SaaS版发布,免费体验降本增效高级功能!
建議收藏!!Flutter狀態管理插件哪家强?請看島上碼農的排行榜!
Introduction to FLIR blackfly s industrial camera
随机推荐
pgpool-II和pgpoolAdmin的使用
投资的再思考
Jacob Steinhardt, assistant professor of UC Berkeley, predicts AI benchmark performance: AI has made faster progress in fields such as mathematics than expected, but the progress of robustness benchma
【服务器数据恢复】raid损坏导致戴尔某型号服务器崩溃的数据恢复案例
Date processing tool class dateutils (tool class 1)
Livox激光雷达硬件时间同步---PPS方法
Sensor: introduction of soil moisture sensor (xh-m214) and STM32 drive code
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
传感器:DS1302时钟芯片及驱动代码
Flir Blackfly S工业相机:颜色校正讲解及配置与代码设置方法
Tiflash source code reading (IV) design and implementation analysis of tiflash DDL module
组合导航:中海达iNAV2产品描述及接口描述
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
Data connection mode in low code platform (Part 1)
The boss is quarantined
Redis configuration class redisconfig
低代码平台中的数据连接方式(上)
Robot team learning method to achieve 8.8 times human return
centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins
go swagger使用