# Stream Aggregate

+ Stream Aggregate example
  + `EXPLAIN SELECT /*+ STREAM_AGG() */ col1, count(*) FROM t2 GROUP BY col1;` 
```
+------------------------------------+------------+------------+-------------------+-----------------------------------------------------------------------------------------------+
| id                                 | estRows    | task       | access object     | operator info                                                                                 |
+------------------------------------+------------+------------+-------------------+-----------------------------------------------------------------------------------------------+
| Projection_4                       | 8000.00    | root       |                   | test.t2.col1, Column#3                                                                        |
| └─StreamAgg_8                      | 8000.00    | root       |                   | group by:test.t2.col1, funcs:count(1)->Column#3, funcs:firstrow(test.t2.col1)->test.t2.col1   |
|   └─Sort_13                        | 10000.00   | root       |                   | test.t2.col1                                                                                  |
|     └─TableReader_12               | 10000.00   | root       |                   | data:TableFullScan_11                                                                         |
|       └─TableFullScan_11           | 10000.00   | cop[tikv]  | table:t2          | keep order:false, stats:pseudo                                                                |
+------------------------------------+------------+------------+------------ ------+-----------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec)
```
------------------------------------------------------------
Stream Aggregate example
Stream Aggregate operator
The Stream Aggregation operator typically uses less memory than a Hash Aggregate, and in some scenario performs faster than a Hash Aggregate. You can try the Stream Aggregate operator when the amount of data is too large or the system is low on memory. With the STREAM_AGG hint, we can force the execution plan to go through the stream aggregate operator.
