set tidb_cost_model_version=1; create table t(a int, b int, c int); desc format='brief' select a, b, avg(c) from t group by a, b, c having (a > 1) and (a > 2) and 1 and (b > 2) and (avg(c) > 3); id estRows task access object operator info Projection 711.11 root agg_predicate_pushdown.t.a, agg_predicate_pushdown.t.b, Column#5->Column#8 └─Selection 711.11 root gt(Column#5, 3) └─HashAgg 888.89 root group by:Column#14, Column#15, Column#16, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->agg_predicate_pushdown.t.a, funcs:firstrow(Column#15)->agg_predicate_pushdown.t.b └─Projection 1111.11 root cast(agg_predicate_pushdown.t.c, decimal(10,0) BINARY)->Column#13, agg_predicate_pushdown.t.a->Column#14, agg_predicate_pushdown.t.b->Column#15, agg_predicate_pushdown.t.c->Column#16 └─TableReader 1111.11 root data:Selection └─Selection 1111.11 cop[tikv] gt(agg_predicate_pushdown.t.a, 1), gt(agg_predicate_pushdown.t.a, 2), gt(agg_predicate_pushdown.t.b, 2) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo desc format='brief' select a, b, avg(c) from t group by a, b, c having (a > 1 or b > 2) and (a > 2 or b < 1) and 1 and (b > 2) and (avg(c) > 3); id estRows task access object operator info Projection 657.65 root agg_predicate_pushdown.t.a, agg_predicate_pushdown.t.b, Column#5->Column#8 └─Selection 657.65 root gt(Column#5, 3) └─HashAgg 822.06 root group by:Column#14, Column#15, Column#16, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->agg_predicate_pushdown.t.a, funcs:firstrow(Column#15)->agg_predicate_pushdown.t.b └─Projection 1027.57 root cast(agg_predicate_pushdown.t.c, decimal(10,0) BINARY)->Column#13, agg_predicate_pushdown.t.a->Column#14, agg_predicate_pushdown.t.b->Column#15, agg_predicate_pushdown.t.c->Column#16 └─TableReader 1027.57 root data:Selection └─Selection 1027.57 cop[tikv] gt(agg_predicate_pushdown.t.b, 2), or(gt(agg_predicate_pushdown.t.a, 1), gt(agg_predicate_pushdown.t.b, 2)), or(gt(agg_predicate_pushdown.t.a, 2), lt(agg_predicate_pushdown.t.b, 1)) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo desc format='brief' select a, b, avg(c) from t group by a, b, c having (a > 1 and b > 2) or (a > 2 and b < 1) or (b > 2 and avg(c) > 3); id estRows task access object operator info Projection 3027.54 root agg_predicate_pushdown.t.a, agg_predicate_pushdown.t.b, Column#5->Column#8 └─Selection 3027.54 root or(and(gt(agg_predicate_pushdown.t.a, 1), gt(agg_predicate_pushdown.t.b, 2)), or(and(gt(agg_predicate_pushdown.t.a, 2), lt(agg_predicate_pushdown.t.b, 1)), and(gt(agg_predicate_pushdown.t.b, 2), gt(Column#5, 3)))) └─HashAgg 3784.43 root group by:Column#14, Column#15, Column#16, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->agg_predicate_pushdown.t.a, funcs:firstrow(Column#15)->agg_predicate_pushdown.t.b └─Projection 4730.53 root cast(agg_predicate_pushdown.t.c, decimal(10,0) BINARY)->Column#13, agg_predicate_pushdown.t.a->Column#14, agg_predicate_pushdown.t.b->Column#15, agg_predicate_pushdown.t.c->Column#16 └─TableReader 4730.53 root data:Selection └─Selection 4730.53 cop[tikv] or(and(gt(agg_predicate_pushdown.t.a, 1), gt(agg_predicate_pushdown.t.b, 2)), or(and(gt(agg_predicate_pushdown.t.a, 2), lt(agg_predicate_pushdown.t.b, 1)), gt(agg_predicate_pushdown.t.b, 2))) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo desc format='brief' select a, b, avg(c) from t group by a, b, c having (a > 1 or avg(c) > 1) and (a < 3); id estRows task access object operator info Projection 2126.93 root agg_predicate_pushdown.t.a, agg_predicate_pushdown.t.b, Column#5->Column#8 └─Selection 2126.93 root or(gt(agg_predicate_pushdown.t.a, 1), gt(Column#5, 1)) └─HashAgg 2658.67 root group by:Column#14, Column#15, Column#16, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->agg_predicate_pushdown.t.a, funcs:firstrow(Column#15)->agg_predicate_pushdown.t.b └─Projection 3323.33 root cast(agg_predicate_pushdown.t.c, decimal(10,0) BINARY)->Column#13, agg_predicate_pushdown.t.a->Column#14, agg_predicate_pushdown.t.b->Column#15, agg_predicate_pushdown.t.c->Column#16 └─TableReader 3323.33 root data:Selection └─Selection 3323.33 cop[tikv] lt(agg_predicate_pushdown.t.a, 3) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo desc format='brief' select a, b, avg(c) from t group by a, b, c having (a > 1 and avg(c) > 1) or (a < 3); id estRows task access object operator info Projection 6393.60 root agg_predicate_pushdown.t.a, agg_predicate_pushdown.t.b, Column#5->Column#8 └─Selection 6393.60 root or(and(gt(agg_predicate_pushdown.t.a, 1), gt(Column#5, 1)), lt(agg_predicate_pushdown.t.a, 3)) └─HashAgg 7992.00 root group by:Column#14, Column#15, Column#16, funcs:avg(Column#13)->Column#5, funcs:firstrow(Column#14)->agg_predicate_pushdown.t.a, funcs:firstrow(Column#15)->agg_predicate_pushdown.t.b └─Projection 9990.00 root cast(agg_predicate_pushdown.t.c, decimal(10,0) BINARY)->Column#13, agg_predicate_pushdown.t.a->Column#14, agg_predicate_pushdown.t.b->Column#15, agg_predicate_pushdown.t.c->Column#16 └─TableReader 9990.00 root data:Selection └─Selection 9990.00 cop[tikv] or(gt(agg_predicate_pushdown.t.a, 1), lt(agg_predicate_pushdown.t.a, 3)) └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo