# Hash Aggregation Function Operator - `HashAgg`

+ **`HashAgg`** uses a hash table to store intermediate results while performing aggregation in parallel
+ **`HashAgg`** can be pushed down to TiKV layer for execution
+ **`HashAgg`** is a blocking node in the execution flow

![`smart`](TiDBDistSQLFlowCountHireDate_en_001_20240408.png)

```6
tidb> EXPLAIN SELECT COUNT(hire_date) FROM employees;
+----------------------+-----------+-----------+-----------------+------------------------------------------------------+
| id                   | estRows   | task      | access object   | operator info                                        |
+----------------------+-----------+-----------+-----------------+------------------------------------------------------+
| ~!@HashAgg@!~_11           | 1.00      | root      |                 | funcs:count(Column#8)->Column#7                      |
| └─TableReader_12     | 1.00      | root      |                 | data:HashAgg_5                                       |
|  └─~!@HashAgg@!~_5         | 1.00      | cop[tikv] |                 | funcs:count(employees.employees.hire_date)->Column#8 |
|   └─TableFullScan_10 | 300024.00 | cop[tikv] | table:employees | keep order:false                                     |
+----------------------+-----------+-----------+-----------------+------------------------------------------------------+
4 rows in set (0.01 sec)
```

------------------------------------------------------------------------------
Aggregation functions summarize and compute data using SQL functions. These operations provide statistical insights from tables, such as totals, averages, maxima, minima, and counts. Common aggregation functions include `SUM`, `AVG`, `MAX`, `MIN`, and `COUNT`. This section will cover the aggregation algorithms used in TiDB and their applicable scenarios.

It's important to note that aggregation inherently involves data sorting, meaning aggregation algorithms can be seen as sorting processes. We will conclude this section with a summary of suitable scenarios for different aggregation algorithms and how to optimize their use.

In the execution plan shown, the `HashAgg` operator, which is an aggregator function operator, is employed.