pg_table_size,pg_relation_size&之间有什么区别? pg_total_relation_size? (PostgreSQL) [英] What's the difference between pg_table_size, pg_relation_size & pg_total_relation_size? (PostgreSQL)
问题描述
pg_table_size()
, pg_relation_size()
和&的区别是什么? pg_total_relation_size()
?
我理解文档中的,但这意味着我的表实际有多少空间
对于随机表:
#选择pg_relation_size(20306,'main')作为main,
pg_relation_size(20306,'fsm')作为fsm,
pg_relation_size(20306,'vm')作为vm,
pg_relation_size(20306,'init')作为init,
pg_table_size(20306),pg_indexes_size(20306)作为索引,
pg_total_relation_size(20306)作为总索引;
主要| fsm | vm |初始化| pg_table_size |索引|总计
-------- + ------- + ------ + ------ + -------------- -+ --------- + --------
253952 | 24576 | 8192 | 0 | 286720 | 196608 | 483328
(1行)
从中可以看出 pg_table_size
是 pg_relation_size
的所有返回值的总和。 pg_total_relation_size
是 pg_table_size
和 pg_indexes_size
的总和。 / p>
如果您想知道表正在使用多少空间,请使用 pg_table_size
和 pg_total_relation_size
考虑一下-一个数字仅表形式,一个数字是表+索引。
选中存储文件布局以获取有关 fsm
, vm
和 init
的含义以及它们在磁盘上的存储方式。
What's the difference between pg_table_size()
, pg_relation_size()
& pg_total_relation_size()
?
I understand the basic differences explained in the documentation, but what does it imply in terms of how much space my table is actually using?
For a random table:
# select pg_relation_size(20306, 'main') as main,
pg_relation_size(20306, 'fsm') as fsm,
pg_relation_size(20306, 'vm') as vm,
pg_relation_size(20306, 'init') as init,
pg_table_size(20306), pg_indexes_size(20306) as indexes,
pg_total_relation_size(20306) as total;
main | fsm | vm | init | pg_table_size | indexes | total
--------+-------+------+------+---------------+---------+--------
253952 | 24576 | 8192 | 0 | 286720 | 196608 | 483328
(1 row)
From that, you can tell pg_table_size
is the sum of all the return values of pg_relation_size
. And pg_total_relation_size
is the sum of pg_table_size
and pg_indexes_size
.
If you want to know how much space your tables are using, use pg_table_size
and pg_total_relation_size
to think about them -- one number is table-only, and one number is table + indexes.
Check the storage file layout for some info about what fsm
, vm
, and init
mean, and how they're stored on disk.
这篇关于pg_table_size,pg_relation_size&之间有什么区别? pg_total_relation_size? (PostgreSQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!