All Products
Search
Document Center

ApsaraDB RDS:ST_BuildPyramid

Last Updated:Mar 28, 2026

Creates a vector pyramid for a spatial geometry data table to accelerate spatial data rendering.

Syntax

boolean ST_BuildPyramid(cstring table, cstring geom, cstring fid, cstring config)

Parameters

ParameterDescription
tableThe name of the spatial geometry data table.
geomThe name of the geometry column.
fidThe name of the element ID field.
configThe pyramid configuration, specified as a JSON string.

config fields

FieldTypeDefaultDescription
namestringSame as the table nameThe name of the pyramid.
parallelinteger0The maximum number of tasks that run in parallel to build the pyramid. Requires the max_prepared_transactions parameter to be set. Set to 0 to remove the limit.
tileSizeinteger1024The tile size of the pyramid. Valid values: greater than 0 and less than 4096.
tileExtendinteger8The tile extension size of the pyramid. Valid values: greater than 0.
userExtentarray[double]nullThe geographic extent of the pyramid, defined as a JSON array with four values: minx, miny, maxx, and maxy. Set to [] to use a null value.
splitSizeinteger10000The maximum number of elements per index node split. A higher value produces a sparser pyramid.
maxLevelinteger16The maximum number of pyramid levels. Valid values: 0 to 20.
sourceSRSinteger-1The spatial reference system (SRS) of the source data. By default, the function reads the spatial reference identifiers (SRIDs) from the table metadata.
destSRSinteger3857The EPSG code of the tile coordinate system. Valid values: 3857 (EPSG 3857) and 4326 (EPSG 4326).
buildRulesarray[object]nullThe rules for building the pyramid. Multiple rules are supported.

buildRules fields

FieldTypeDescription
levelarray[integer]The pyramid levels to which the rule applies.
valueobjectThe rule configuration. Contains the following sub-fields: filter, attrFields, and merge.
value.filterstringA PostgreSQL filter expression to apply to the data.
value.attrFieldsarray[string]The attribute fields to include when using the Mapbox Vector Tile (MVT) format.
value.mergearray[string]The filter conditions for grouping data records.

config example

{
   "name": "hello",
   "parallel": 4,
   "tileSize": 512,
   "tileExtend": 8,
   "userExtent": [-180, -90, 180, 90],
   "splitSize": 5000,
   "maxLevel": 16,
   "destSRS": 3857,
   "buildRules": [
     {
       "level": [0, 1, 2],
       "value": {
         "filter": "code!=0",
         "attrFields": ["name", "color"],
         "merge": ["code=1"]
       }
     }
   ]
}

Examples

Build a pyramid for a spatial geometry data table named roads:

SELECT ST_BuildPyramid('roads', 'geom', 'id', '');

Expected output:

st_buildpyramid
---------------
t