## Name

ST_MemSize — 返回几何图形占用的内存空间总量。

## Synopsis

`integer ST_MemSize(`geometry geomA`)`;

## 描述

 给出表的字节大小的 pg_relation_size 可能返回小于 ST_MemSize 的字节大小。 这是因为 pg_relation_size 不会添加 toasted 表贡献，并且大型几何图形存储在 TOAST 表中。 pg_total_relation_size - 包括表、压缩表和索引。 pg_column_size 返回考虑到压缩，几何图形在列中占用多少空间，因此可能低于 ST_MemSize

## 示例

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

totgeomsum        bossum        perbos
----------        ------        ------
1522 kB                30 kB        1.99

SELECT ST_MemSize(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_MemSize(geom)) As geomsize,
sum(ST_MemSize(geom))*1.00/pg_total_relation_size('public.neighborhoods')*100 As pergeom
FROM neighborhoods;
fulltable_size geomsize  pergeom
------------------------------------------------
262144         96238         36.71188354492187500000
```