简体   繁体   English

如何测量数据库表中数据的大小?

[英]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.

相关问题 如何衡量数据库索引的成本? - How can I measure the cost of a database index? 如何使用随机数据填充数据库的所有表? - How can I populate my database's all tables with random data? 如何使用SQLLoader直接从tar.gz文件将数据加载到数据库表中? - How can i use SQLLoader to load data into my Database tables directly from a tar.gz file? 如何使用android中的数据库减少我的应用程序大小 - how can i reduce my App size with database in android 如何显示来自 2 个数据库表的一组数据? 窗体 - How can I display a set of data from 2 database tables? Winforms Android:如何在数据库中检索我的期望数据 - Android : How can I retrieve my desire data in my Database 由于我链接了表格(PHP),因此无法从数据库获取数据 - Can't get data from database since I linked my tables (PHP) 我无法删除数据库或更改MySQL中的表 - I can't drop my database or alter my tables in MySQL 我怎样才能以一种可以随时重新排列它们的顺序的方式来构建我的数据库表? - How can I structure my database tables in such a way that their orders can be rearranged at any time? 如何在SQL Server中将表的数据从database1复制和覆盖到database2 - How can I copy and overwrite data of tables from database1 to database2 in SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM