Use ST_SetTypeStorage to set the storage mode for specific data types

更新时间:
复制 MD 格式

Sets the storage mode for geometry or geography data types, controlling how many bytes are stored in-row versus off-row.

Syntax

bool ST_SetTypeStorage(cstring typeName, cstring storageStrategy, integer size);

Parameters

Parameter Description
typeName The data type to configure. Valid values: geometry, geography.
storageStrategy The storage strategy. Set to main.
size The number of bytes to store in-row.

Description

For spatial objects with large per-row sizes, storing metadata in-row and entity data off-row reduces disk I/O. During typical query and analysis workloads, PolarDB reads only the in-row metadata.

The size parameter controls how many bytes remain in-row. Setting size to 0 still uses main mode.

Use the following recommended values as a starting point:

Data type Dimension Recommended value (bytes)
geometry 2d (x,y) 24
3d (x,y,z) and 3dm (x,y,m) 32
4d (x,y,z,m) 40
geography 2d (x,y) 32

Example

Set the in-row storage size for geometry to 41 bytes:

SELECT ST_SetTypeStorage('geometry', 'main', 41);
 st_settypestorage
-------------------
 t
(1 row)

The function returns t (true) on success.