ST_MemUnion — Aggregate function which unions geometry in a memory-efficent but slower way
geometry ST_MemUnion(geometry set geomfield
Unions the input geometries, merging geometry to produce a result geometry with no overlaps. The output may be a single geometry, a MultiGeometry, or a Geometry Collection.
Produces the same result as ST_Union, but uses less memory and more processor time. This aggregate function works by unioning the geometries incrementally, as opposed to the ST_Union aggregate which first accumulates an array and then unions the contents using a fast algorithm.
This function supports 3d and will not drop the z-index. However, the result is computed using XY only. The result Z values are copied, averaged or interpolated.