[GIS] Should I split MultiPolygons into Polygons

performancepolygonpostgis

In the system I'm implementing I have a table T1 with an associated geometry. Most of the geometries are a set of n polygons, with 10 < n < 100.
At the moment in the table T1 I have a geometry column of type MultiPolygon, having a GiST index.

As the table T1 is going to be large, I'm afraid that it would be better to create a one-to-many relation with a second table T2, having a column of type Polygon, and split each MultiPolygon in several Polygons.

But I have to implement searches on the table T1, therefore with the second approach the drawback is that I have an additional join to handle. Furthermore it would be more complicated to insert a geometry for a single record of the table T1.

I am wondering if anyone has any experience with such an issue and if that person could shed some light.

Best Answer

I'd be inclined to say not to worry about the size of your T1 table; indexes (and triggers of course) are what affect performance for the most part.

In addition to having one fewer joins, the translation of WKB to the internal PostGIS/GEOS representation I would imagine would be slightly more optimal than doing it for several polygons individually.

The only need for having a separate geometry table would be if one polygon was associated to more than one record. Multipolygons should be considered a single entity for the purposes of database design, and only if the relationship is more complex should you consider a separate table. And there would be a slight physical space saving with fewer tables.

Try it with both setups, and running the query in pgadmin which gives you the timings for each part of the query.

Related Question