Skip to main content
added 7 characters in body
Source Link
tumasgiu
  • 361
  • 4
  • 10

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two single geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*mn*m multipolygons, where nn is the row count of your first table and mm the count of the second one. This is called a cartesian product.

To accomplish what you want, you need to use the aggregate version, that will behave like the sql-standard sum function. Something like :

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*m multipolygons, where n is the row count of your first table and m the count of the second one. This is called a cartesian product.

To accomplish what you want, you need to use the aggregate version, that will behave like the sql-standard sum function. Something like :

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two single geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*m multipolygons, where n is the row count of your first table and m the count of the second one. This is called a cartesian product.

To accomplish what you want, you need to use the aggregate version, that will behave like the sql-standard sum function. Something like :

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo
added 16 characters in body
Source Link
tumasgiu
  • 361
  • 4
  • 10

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*m multipolygons, where n is the row count of your first table and m the count of the second one. This is called a cartesian product.

To accomplish what you want, you need to use the aggregate version, that will behave like the sql-standard sum function. Something like :

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*m multipolygons, where n is the row count of your first table and m the count of the second one. This is called a cartesian product

To accomplish what you want, you need to use the aggregate version, that will behave like the sum function. Something like

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*m multipolygons, where n is the row count of your first table and m the count of the second one. This is called a cartesian product.

To accomplish what you want, you need to use the aggregate version, that will behave like the sql-standard sum function. Something like :

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo
Source Link
tumasgiu
  • 361
  • 4
  • 10

St_Union comes in two flavors, aggregate and simple.

In your query you are using the simple one that is creating the union of two geometries.

What you are doing is cross joining your two tables, and make union of every combination of the geometries of your two tables, resulting in n*m multipolygons, where n is the row count of your first table and m the count of the second one. This is called a cartesian product

To accomplish what you want, you need to use the aggregate version, that will behave like the sum function. Something like

SELECT st_union(geom) FROM (SELECT geom FROM table1 UNION SELECT geom FROM table2) as foo