[英]How can I measure the size of my data in database tables?
I have a number of tables containing data (in Postgres), and would like to know how 'big' my data is. 我有许多包含数据的表(在Postgres中),并且想知道我的数据有多大。 How can I measure this?
我该如何衡量?
The only ways I can think of is to either: 我能想到的唯一方法是:
Calculate the size of each row (based on the data types) and multiply by the number of rows (but this won't be accurate when my data is normalized) 计算每行的大小(基于数据类型)并乘以行数(但是当我的数据标准化时,这将不准确)
or: 要么:
Denormalize the data with a bunch of joins and export the result to CSV and look at the size of the file. 通过一堆联接对数据进行非规范化,然后将结果导出为CSV,然后查看文件的大小。
Is there another (easier) way to do this? 还有另一种(更简便的)方法吗?
内置函数pg_database_size()
可用于获取整个数据库的大小(包括索引,内置模式等)。
SELECT pg_size_pretty( pg_database_size( current_database() ) );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.