Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PostgreSQL source code interpretation (58)-query statement # 43 (make_one_rel function # 8 Mel B.

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

< '30000'; 启动gdb跟踪 (gdb) b create_bitmap_heap_pathBreakpoint 1 at 0x78f1c1: file pathnode.c, line 1090.(gdb) cContinuing.Breakpoint 1, create_bitmap_heap_path (root=0x23d93d8, rel=0x248a788, bitmapqual=0x2473a08, required_outer=0x0, loop_count=1, parallel_degree=0) at pathnode.c:10901090 BitmapHeapPath *pathnode = makeNode(BitmapHeapPath); 创建节点,并赋值 1090 BitmapHeapPath *pathnode = makeNode(BitmapHeapPath);(gdb) n1092 pathnode->

(gdb) n1093 pathnode- > path.parent = rel; (gdb) n1094 pathnode- > path.pathtarget = rel- > reltarget; (gdb) n1095 pathnode- > path.param_info = get_baserel_parampathinfo (root, rel, (gdb) 1097 pathnode- > path.parallel_aware = parallel_degree > 0? True: false; (gdb) 1098 pathnode- > path.parallel_safe = rel- > consider_parallel; (gdb) 1099 pathnode- > path.parallel_workers = parallel_degree; (gdb) 1100 pathnode- > path.pathkeys = NIL; / * always unordered * / (gdb) 1102 pathnode- > bitmapqual = bitmapqual

Enter the cost_bitmap_heap_scan function

(gdb) 1104 cost_bitmap_heap_scan (& pathnode- > path, root, rel, (gdb) stepcost_bitmap_heap_scan (path=0x24737d8, root=0x23d93d8, baserel=0x248a788, param_info=0x0, bitmapqual=0x2473a08, loop_count=1) at costsize.c:949949 Cost startup_cost = 0

Enter parameters, where bitmapqual is the T_IndexPath node

Other key information of the path: rows = 2223, startup_cost = 0.285000000000003, total_cost = 169.23871600907944

(gdb) p * (IndexPath *) bitmapqual$2 = {path = {type = T_IndexPath, pathtype = T_IndexScan, parent = 0x248a788, pathtarget = 0x248a998, param_info = 0x0, parallel_aware = false, parallel_safe = true, parallel_workers = 0, rows = 2223, startup_cost = 0.285000000000003, total_cost = 169.23871600907944, pathkeys = 0x0}, indexinfo = 0x23b63b8, indexclauses = 0x2473948, indexquals = 0x2473b38, indexqualcols = 0x2473b88, indexorderbys = 0x0, indexorderbycols = 0x0, 0x0 = 0x0, indexscandir = 50.515000000000001, indexscandir = 0.2222719101235958}}

Start to calculate the cost

.. 980 startup_cost + = indexTotalCost; (gdb) p indexTotalCost$16 = 51.070750000000004 (gdb) p startup_cost$17 = 0 (gdb) p pages_fetched$18 = 64 (gdb) p baserel- > pages$19 = 64. (gdb) p qpqual_cost$20 = {startup = 0, per_tuple = 0.005000000000001}

Final access path information

(gdb) p * (BitmapHeapPath *) path$22 = {path = {type = T_BitmapHeapPath, pathtype = T_BitmapHeapScan, parent = 0x248a788, pathtarget = 0x248a998, param_info = 0x0, parallel_aware = false, parallel_safe = true, parallel_workers = 0, rows = 2223, startup_cost = 51.070750000000004, total_cost = 148.41575, pathkeys = 0x0}, bitmapqual = 0x2473a08}

In addition to BitmapHeapPath, there are BitmapOr and BitmapAnd, which will be described in more detail later.

IV. Reference materials

Allpaths.c

Cost.h

Costsize.c

PG Document:Query Planning

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report