PostgreSQL source code interpretation (58)-query statement # 43 (make_one_rel function # 8 Mel B.
(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