当前位置:网站首页>postgresql之整體查詢大致過程
postgresql之整體查詢大致過程
2022-07-07 02:20:00 【happytree001】
客戶端通過pg服務器查詢的大致過程如下
一、 建立連接
客戶端首先需要連接上pg服務器,服務器在和客戶端建立連接後fork一個子進程處理後續客戶端的請求,服務器然後等待下一個客戶端的連接。
二、發送請求
客戶端發送請求數據給pg服務器,pg子進程讀取請求。
- 客戶端發送請求
比如命令行,讀取用戶輸入,發送給服務器src/bin/psql/mainloop.c
int
MainLoop(FILE *source)
{
...
SendQuery(query_buf->data);
...
}
- 服務器接收請求
void
PostgresMain(int argc, char *argv[],
const char *dbname,
const char *username)
{
...
for (;;)
{
...
firstchar = ReadCommand(&input_message);
...
}
}
三、解析
以簡單查詢為例子。服務器接收到的是一串字符串,需要解析理解這個數據才能執行。
src/backend/tcop/postgres.c
static void
exec_simple_query(const char *query_string)
{
...
parsetree_list = pg_parse_query(query_string);
...
}
通過詞法以及語法解析,構建一個原始的語法樹。
四、優化
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);
..
}
將原始的語法樹轉化為一個查詢樹,並且對查詢樹進行優化以及重寫,提昇執行速度。
五、執行
static void
exec_simple_query(const char *query_string)
{
...
(void) PortalRun(portal,
FETCH_ALL,
true, /* always top level */
true,
receiver,
receiver,
&qc);
...
}
六、返回結果
具體函數還為找到
边栏推荐
- 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
- 强化学习如何用于医学影像?埃默里大学最新《强化学习医学影像分析》综述,阐述最新RL医学影像分析概念、应用、挑战与未来方向
- [paper reading | deep reading] dngr:deep neural networks for learning graph representations
- Command injection of cisp-pte
- RC振荡器和晶体振荡器简介
- What to do when encountering slow SQL? (next)
- 老板被隔离了
- 大咖云集|NextArch基金会云开发Meetup来啦!
- Yyds dry goods inventory # solve the real problem of famous enterprises: maximum difference
- String or binary data will be truncated
猜你喜欢
云原生混部最后一道防线:节点水位线设计
2022/0524/bookstrap
FLIR blackfly s usb3 industrial camera: how to use counters and timers
Livox激光雷达硬件时间同步---PPS方法
[paper reading | deep reading] dngr:deep neural networks for learning graph representations
The last line of defense of cloud primary mixing department: node waterline design
STM32F4---通用定时器更新中断
Flir Blackfly S 工业相机:自动曝光配置及代码
强化学习如何用于医学影像?埃默里大学最新《强化学习医学影像分析》综述,阐述最新RL医学影像分析概念、应用、挑战与未来方向
红外相机:巨哥红外MAG32产品介绍
随机推荐
ROS learning (XX) robot slam function package -- installation and testing of rgbdslam
FLIR blackfly s industrial camera: synchronous shooting of multiple cameras through external trigger
RC振荡器和晶体振荡器简介
Batch delete data in SQL - set in entity
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
postgresql之整体查询大致过程
UC伯克利助理教授Jacob Steinhardt预测AI基准性能:AI在数学等领域的进展比预想要快,但鲁棒性基准性能进展较慢
Input and output of C language pointer to two-dimensional array
Metaforce force meta universe development and construction - fossage 2.0 system development
Tiflash source code reading (IV) design and implementation analysis of tiflash DDL module
Analyze "C language" [advanced] paid knowledge [i]
使用Ceres进行slam必须要弄清楚的几个类和函数
SchedulX V1.4.0及SaaS版发布,免费体验降本增效高级功能!
Halcon knowledge: segment_ contours_ XLD operator
Flir Blackfly S 工业相机:通过外部触发实现多摄像头同步拍摄
传感器:DS1302时钟芯片及驱动代码
[unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
Correct use of BigDecimal
Seconds understand the delay and timing function of wechat applet
Introduction to microservice architecture