For lines, the length is calculated by the ST_Length function. It takes one argument, the input geometry, which can be a LineString or MultiLineString. When the argument is of the geometry type, the planimetric calculation will take place and the output length will be given in units of the input geometry's coordinate system.
Here is an example of a three-point LineString:
SELECT ST_Length(
ST_MakeLine(ARRAY[ST_MakePoint(391390,5817855),ST_MakePoint(391490,5817955), ST_MakePoint(391590,5818055)])
);
st_length
------------------
282.842712474619
For latitude-longitude coordinates, either the geography type, a type cast, or a ST_Length_Spheroid function should be used. Here is an example of a type cast being used:
SELECT ST_Length(
ST_MakeLine(ARRAY[ST_MakePoint(20,50),ST_MakePoint(19.95,49.98), ST_MakePoint(19.90,49.96)])::geography
);
st_length
------------------
8440.40084752485
The result will be given in meters.
For polygons, perimeter and area calculations are available.