导入后 CloudSQL 实例的存储使用量较少
CloudSQL instance has less storage usage after importing
我有一个包含 112.7 GB 数据的 CloudSQL 实例 (PostgreSQL):
我想把这个实例中的数据转移到另一个实例中。
我先做了一个导出,然后创建了另一个实例并在那里导入了数据。
一切顺利。但是,生成的实例的存储使用量较少,只有 102 GB:
在日志中没有发现错误。我想知道10GB的数据去了哪里
这是预期的吗?
这是由于 table 中的碎片造成的。在MySQL的情况下:
One symptom of fragmentation is that a table takes more space than it
“should” take. How much that is exactly, is difficult to determine.
All InnoDB data and indexes are stored in B-trees, and their fill
factor may vary from 50% to 100%. Another symptom of fragmentation is
that a table scan such as this takes more time than it “should”
take:...
在PostgreSQL docs中(参见23.1.2. Recovering Disk Space部分),解释为:
In PostgreSQL, an UPDATE or DELETE of a row does not immediately
remove the old version of the row. This approach is necessary to gain
the benefits of multiversion concurrency control (MVCC, see Chapter
13): the row version must not be deleted while it is still potentially
visible to other transactions. But eventually, an outdated or deleted
row version is no longer of interest to any transaction. The space it
occupies must then be reclaimed for reuse by new rows, to avoid
unbounded growth of disk space requirements. This is done by running
VACUUM.
另请阅读 Vacuum the Dirt out of Your Database 文档以查看解决此问题的步骤。
希望这对您有所帮助。
我有一个包含 112.7 GB 数据的 CloudSQL 实例 (PostgreSQL):
我想把这个实例中的数据转移到另一个实例中。
我先做了一个导出,然后创建了另一个实例并在那里导入了数据。
一切顺利。但是,生成的实例的存储使用量较少,只有 102 GB:
在日志中没有发现错误。我想知道10GB的数据去了哪里
这是预期的吗?
这是由于 table 中的碎片造成的。在MySQL的情况下:
One symptom of fragmentation is that a table takes more space than it “should” take. How much that is exactly, is difficult to determine. All InnoDB data and indexes are stored in B-trees, and their fill factor may vary from 50% to 100%. Another symptom of fragmentation is that a table scan such as this takes more time than it “should” take:...
在PostgreSQL docs中(参见23.1.2. Recovering Disk Space部分),解释为:
In PostgreSQL, an UPDATE or DELETE of a row does not immediately remove the old version of the row. This approach is necessary to gain the benefits of multiversion concurrency control (MVCC, see Chapter 13): the row version must not be deleted while it is still potentially visible to other transactions. But eventually, an outdated or deleted row version is no longer of interest to any transaction. The space it occupies must then be reclaimed for reuse by new rows, to avoid unbounded growth of disk space requirements. This is done by running VACUUM.
另请阅读 Vacuum the Dirt out of Your Database 文档以查看解决此问题的步骤。
希望这对您有所帮助。