You are on page 1of 2

PostGIS 1.5.

1 Manual
263 / 315

Synopsis
integer ST_Mem_Size(geometry geomA);

Description
Returns the amount of space (in bytes) the geometry takes.
This is a nice compliment to PostgreSQL built in functions pg_size_pretty, pg_relation_size, pg_total_relation_size.
Note
pg_relation_size which gives the byte size of a table may return byte size lower than ST_Mem_Size. This is because
pg_relation_size does not add toasted table contribution and large geometries are stored in TOAST tables.
pg_total_relation_size - includes, the table, the toasted tables, and the indexes.

This function supports 3d and will not drop the z-index.


This method supports Circular Strings and Curves

Examples
--Return how much byte space Boston takes up in our Mass data set
SELECT pg_size_pretty(SUM(ST_Mem_Size(the_geom))) as totgeomsum,
pg_size_pretty(SUM(CASE WHEN town = BOSTON THEN st_mem_size(the_geom) ELSE 0 END)) As
bossum,
CAST(SUM(CASE WHEN town = BOSTON THEN st_mem_size(the_geom) ELSE 0 END)*1.00 /
SUM(st_mem_size(the_geom))*100 As numeric(10,2)) As perbos
FROM towns;

totgeomsum bossum perbos


---------- ------ -----1522 kB
30 kB 1.99

SELECT ST_Mem_Size(ST_GeomFromText(CIRCULARSTRING(220268 150415,220227 150505,220227


150406)));

--73
--What percentage of our table is taken up by just the geometry
SELECT pg_total_relation_size(public.neighborhoods) As fulltable_size, sum(ST_Mem_Size( the_geom)) As geomsize,
sum(ST_Mem_Size(the_geom))*1.00/pg_total_relation_size(public.neighborhoods)*100 As pergeom
FROM neighborhoods;
fulltable_size geomsize pergeom
-----------------------------------------------262144
96238
36.71188354492187500000

PostGIS 1.5.1 Manual


264 / 315

See Also
7.12.10 ST_Point_Inside_Circle
Name
ST_Point_Inside_Circle Is the point geometry insert circle defined by center_x, center_y , radius

Synopsis
boolean ST_Point_Inside_Circle(geometry a_point, float center_x, float center_y, float radius);

Description
The syntax for this functions is point_inside_circle(<geometry>,<circle_center_x>,<circle_center_y>,<radius>). Returns the
true if the geometry is a point and is inside the circle. Returns false otherwise.

Note This only works for points as the name suggests

Examples
SELECT ST_Point_Inside_Circle(ST_Point(1,2), 0.5, 2, 3);
st_point_inside_circle
-----------------------t

See Also
ST_DWithin

7.12.11 ST_XMax
Name
ST_XMax Returns X maxima of a bounding box 2d or 3d or a geometry.

Synopsis
float ST_XMax(box3d aGeomorBox2DorBox3D);

You might also like