Name

ST_MemUnion — Same as ST_Union (aggregate) but memory-friendly (uses less memory and more processor time).

Synopsis

PostgreSQL

geometry ST_MemUnion(bytea GeometryAggregate);

H2

geometry ST_MemUnionAgg(bytea GeometryAggregate);

Alias

MemUnion

Description

Same as ST_Union (aggregate) but memory-friendly (uses less memory and more processor time). It works by unioning the geometries one at a time to previous result as opposed to ST_Union aggregate which first creates an array and then unions

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

CREATE TABLE "polygons"(id serial PRIMARY KEY);
SELECT AddGeometryColumn ('polygons','GEOM',25830,'POLYGON',2);

INSERT INTO "polygons" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;POLYGON ((40 20 10, 40 100 15, 120 100 25, 120 20 30, 40 20 25))'));
INSERT INTO "polygons" ("GEOM") VALUES (ST_GeomfromEWKT('SRID=25830;POLYGON ((80 60, 80 130, 170 130, 170 60, 80 60))'));

--PostgreSQL
SELECT asewkt(ST_MemUnion("polygons"."GEOM")) as union_pol from "polygons";
--H2
SELECT asewkt(ST_MemUnionAgg("polygons"."GEOM")) as union_pol from "polygons";
SELECT DropGeometryTable ('polygons');

--Result
UNION_POL  
SRID=25830;POLYGON ((40 20 10, 40 100 15, 80 100 0, 80 130 0, 170 130 0, 170 60 0, 120 60 0, 120 20 30, 40 20 25))

Related functions

ST_Union