group by 系列

文章目录

  • select max(id2) from test1 group by id1 ;
  • 看看have_grouping这个变量的四个组成部分

select max(id2) from test1 group by id1 ;

  • 刚进入create_plan的时候,你猜猜这个*best_path是啥呢?
(gdb) print (*best_path)
$1 = {
     type = T_AggPath, pathtype = T_Agg, parent = 0x13cc168, 
  pathtarget = 0x13cbe88, param_info = 0x0, parallel_aware = false, 
  parallel_safe = true, parallel_workers = 0, rows = 200, 
  startup_cost = 43.899999999999999, total_cost = 45.899999999999999, 
  pathkeys = 0x0}
  • 结果是个T_AggPath哦!

看看have_grouping这个变量的四个组成部分

have_grouping = (parse->groupClause || parse->groupingSets ||
						 parse->hasAggs || root->hasHavingQual);
  • 先看看断点在

break planner.c:1965

  • 此时我打印
(gdb) print(parse->groupClause)
$2 = (List *) 0x13caa88
(gdb) print(parse->groupingSets)
$3 = (List *) 0x0
(gdb) print(parse->hasAggs)
$4 = true
(gdb) print(root->hasHavingQual)
$5 = false

你可能感兴趣的:(pgsql11.2源码)