Abstract plans for queries containing aggregates

This query returns a scalar aggregate:

select max(c11) from t1

There is a physical operator that implements scalar aggregation, therefore, the optimizer has no choice. However, choosing an index on c11 allows the max() optimization:

(scalar_agg
  (i_scan ic11 t1) 
) 

Since the scalar aggregate is the top abstract plan operator, removing it and using the following partial plan has the same outcome:

(i_scan ic11 t1)

The scalar_agg abstract plan is typically needed when it is part of a subquery and the abstract plan must cover the parent query as well.

Vector aggregation is different, in that there are several physical operators to implement the group logical operator, which means that the optimizer has a choice to make. Thus, the abstract plan can force it.

select max(c11)
from t1
group by c12

The following abstract plan examples force each of the three vector aggregation algorithms:

Notegroup_sorted requires an ordering on the grouping column, so it needs to use an index.

(group_sorted
  (i_scan i_c12 t1)
)
(group_hashing
  (t_scan t1)
)

(group_inserting
  (t_scan t1)
)