ST_Subdivide

更新时间: 2026-03-28 06:04:51

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

ParameterDescription
geomThe geometry to subdivide.
maxVerticesThe 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 a SELECT list or a FROM clause 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);
1

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.

上一篇: ST_SymDifference 下一篇: ST_SwapOrdinates
阿里云首页 云原生数据库 PolarDB 相关技术圈