# `StreamAgg` Process - Cont'd

![`smart`](STREAMAGG02_aa_003_20231013.png)

------------------------------------------------------------------------------
In the slide, since the table is sorted by `Dept.`, aggregation for the `Dev.` department is completed first. If the SQL query only requires results for the `Dev.` department, the scan of the entire table can be terminated early.

This non-blocking algorithm is more efficient than the blocking algorithm used by the `HashAgg` operator, which requires scanning the entire table to obtain results. Once aggregation for the `Dev.` department is finished, the scan moves on to the `Opt.` department, continuing in a similar manner.

