The perimeter is computed using the ST_Perimeter function. Its usage is identical to ST_Length, the only difference being that the argument must be a polygon or MultiPolygon:
SELECT ST_Perimeter(ST_GeomFromText('POLYGON((391390 5817855,391490 5817955,391590 5818055, 319590 5817855,391390 5817855))', 32633))
st_perimeter
------------------
144083.120489717
Again, for latitude-longitude coordinates, the geography type should be used. Please note that in contrast to distance and length computations, there's no specialized function for the geodesic calculation of the perimeter of latitude-longitude geometry. Here is an example, using the triangle from previous section:
SELECT ST_Perimeter(
ST_MakePolygon(ST_MakeLine(ARRAY[ST_MakePoint(20,50),ST_MakePoint(19.95,49.98), ST_MakePoint(19.90,49.90),ST_MakePoint(20,50)]))::geography
);
st_perimeter
------------------
27051.7310753665
When a polygon has holes, the perimeter of the interior rings will be added to the exterior rings' perimeter:
SELECT ST_Perimeter(ST_MakePolygon(
ST_MakeLine(ARRAY[ST_MakePoint(20,50),ST_MakePoint(19.95,49.98), ST_MakePoint(19.90,49.90),ST_MakePoint(20,50)]),
ARRAY[ST_MakeLine(ARRAY[ST_MakePoint(19.95,49.97),ST_MakePoint(19.943,49.963), ST_MakePoint(19.955,49.965),ST_MakePoint(19.95,49.97)])]
)::geography);
st_perimeter
------------------
29529.3133397193