ST_Subdivide
Computes a rectilinear subdivision of a geometry, splitting it into parts until each part has fewer vertices than maxVertices.
Syntax
SETOF geometry ST_Subdivide(geometry geom, integer maxVertices = 256);Parameters
| Parameter | Description |
|---|---|
geom | The geometry to subdivide. |
maxVertices | The maximum number of vertices per subdivision. Default value: 256. Minimum value: 5. |
How it works
ST_Subdivide splits a complex geometry into smaller parts using rectilinear (axis-aligned) cuts. Each resulting part has fewer vertices than maxVertices.
Spatial queries run faster on subdivided geometries for two reasons:
Smaller bounding boxes: In most cases, each subdivision's bounding box is smaller than the original geometry's bounding box, so index lookups exclude more candidates without a recheck.
Fewer recheck candidates: Fewer points fall within each subdivision's bounding box, so the recheck step processes less data.
This makes ST_Subdivide especially effective for point-in-polygon queries and spatial joins against large, complex geometries.
ST_Subdivide is a set-returning function (SRF). It returns one row per subdivision, not a single geometry value. Use it in aSELECTlist or aFROMclause accordingly.
Examples
Subdivide a polygon
Subdivide a circle (approximated as a polygon by ST_Buffer) into parts with at most 6 vertices each:
SELECT ST_Subdivide(ST_Buffer('POINT(0 0)'::geometry, 1), 6);
What's next
ST_NPoints — Count vertices in a geometry to decide whether subdivision is needed.
ST_Buffer — Generate polygon approximations of geometric shapes.
ST_Split — Split a geometry by a blade geometry.