ST_MemSize — 返回几何体占用的内存空间量。
integer ST_MemSize(
geometry geomA)
;
返回几何体占用的内存空间量(以字节为单位)。
这补充了 PostgreSQL 内置的 数据库对象函数 pg_column_size、pg_size_pretty、pg_relation_size、pg_total_relation_size。
pg_relation_size 提供表的字节大小,返回的字节大小可能低于 ST_MemSize。这是因为 pg_relation_size 不添加烤制表贡献,而大型几何体存储在 TOAST 表中。 pg_total_relation_size - 包括表、烤制表和索引。 pg_column_size 返回几何体在列中占用的空间,考虑了压缩,因此可能低于 ST_MemSize |
此函数支持 3d,不会删除 z 索引。
此方法支持圆形字符串和曲线。
此函数支持多面体表面。
此函数支持三角形和三角形不规则网络表面 (TIN)。
已更改:2.2.0 名称已更改为 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