Name

ST_UnaryUnion — Like ST_Union, but working at the geometry component level.

Synopsis

geometry ST_UnaryUnion(geometry geom);

Description

Unlike ST_Union, ST_UnaryUnion does dissolve boundaries
between components of a multipolygon (invalid)
and does perform union between the components of a
geometrycollection.
Each components of the input geometry is assumed to be
valid, so you won't get a valid multipolygon out of a
bow-tie polygon (invalid).

You may use this function to node a set of linestrings.
You may mix ST_UnaryUnion with ST_Collect to fine-tune
how many geometries at once you want to dissolve to
be nice on both memory size and CPU time, finding the
balance between ST_Union and ST_MemUnion.