This function was previously named ST_Union_Aggr, which is deprecated since v1.8.1.
Without GROUP BY, the final merge runs in a single task and returns a single geometry, so its run time and memory grow with the size of the result. For region-scale dissolves, such as polygonized raster masks with hundreds of thousands of polygons, drop slivers first and group by a spatial key such as a tile id, so the groups are dissolved in parallel. Then keep the per-group results, or union them with a second ST_Union_Agg:
WITH per_tile AS ( SELECT tile_id, ST_Union_Agg(geom) AS geom FROM polygons WHERE ST_Area(geom) >= 400 GROUP BY tile_id)SELECT ST_Union_Agg(geom) AS geom FROM per_tile