mysqldump .sql文件大小是数据库大小计算的10%(计算时不包括索引)

时间:2019-05-06 18:51:23

标签: mysql

数据库DB1估计为48 KB,而我转储到的.sql文件为4.7998 KB-几乎恰好是大小的10%。不管大小下降,请注意,数据库大小是在没有索引的情况下估算的,因此似乎无法解释它。

我尝试了几种不同的尺寸估算方法,它们报告的结果相同。

MariaDB [information_schema]> SELECT table_schema
    -> AS "Database",
    -> SUM(data_length + index_length) AS "Size (Bytes)",
    -> ROUND(SUM(data_length + index_length) / 1024, 5) AS "Size (KB)",
    -> ROUND(SUM(data_length + index_length) / 1024 / 1024, 5) AS "Size (MB)",
    -> ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 5) AS "Size (GB)"
    -> FROM information_schema.TABLES GROUP BY table_schema;
+--------------------+--------------+-----------+-----------+-----------+
| Database           | Size (Bytes) | Size (KB) | Size (MB) | Size (GB) |
+--------------------+--------------+-----------+-----------+-----------+
| DB1                |        65536 |  64.00000 |   0.06250 |   0.00006 |
| information_schema |       180224 | 176.00000 |   0.17188 |   0.00017 |
| mysql              |       746169 | 728.68066 |   0.71160 |   0.00069 |
| performance_schema |            0 |   0.00000 |   0.00000 |   0.00000 |
+--------------------+--------------+-----------+-----------+-----------+
MariaDB [(none)]> SELECT
    -> table_schema AS "Database",
    -> SUM(data_length) AS "Size (Bytes)",
    -> ROUND(SUM(data_length) / 1024, 5) AS "Size (KB)",
    -> ROUND(SUM(data_length) / 1024 / 1024, 5) AS "Size (MB)",
    -> ROUND(SUM(data_length) / 1024 / 1024 / 1024, 5) AS "Size (GB)"
    -> FROM information_schema.TABLES GROUP BY table_schema;
+--------------------+--------------+-----------+-----------+-----------+
| Database           | Size (Bytes) | Size (KB) | Size (MB) | Size (GB) |
+--------------------+--------------+-----------+-----------+-----------+
| DB1                |        49152 |  48.00000 |   0.04688 |   0.00005 |
| information_schema |        90112 |  88.00000 |   0.08594 |   0.00008 |
| mysql              |       576185 | 562.68066 |   0.54949 |   0.00054 |
| performance_schema |            0 |   0.00000 |   0.00000 |   0.00000 |
+--------------------+--------------+-----------+-----------+-----------+

...

MariaDB [information_schema]> SELECT
    -> table_schema AS "Database",
    -> SUM(data_length) AS "Size (Bytes)",
    -> SUM(data_length) / POWER(1024,1) AS "Size (KB)",
    -> SUM(data_length) / POWER(1024,2) AS "Size (MB)",
    -> SUM(data_length) / POWER(1024,3) AS "Size (GB)"
    -> FROM information_schema.TABLES GROUP BY table_schema;
+--------------------+--------------+----------------+--------------------+-----------------------+
| Database           | Size (Bytes) | Size (KB)      | Size (MB)          | Size (GB)             |
+--------------------+--------------+----------------+--------------------+-----------------------+
| DB1                |        49152 |             48 |           0.046875 |    0.0000457763671875 |
| information_schema |        90112 |             88 |          0.0859375 |   0.00008392333984375 |
| mysql              |       576185 | 562.6806640625 | 0.5494928359985352 | 0.0005366140976548195 |
| performance_schema |            0 |              0 |                  0 |                     0 |
+--------------------+--------------+----------------+--------------------+-----------------------+
me@MyMint:~$ mysqldump -u root -p --databases DB1 > DB1_dataBU_$(date +%Y%m%d).sql
Enter password:
me@MyMint:~$ du -sb DB1_dataBU_20190506.sql
4915    DB1_dataBU_20190506.sql
me@MyMint:~$ ls -lh DB1_dataBU_20190506.sql;
-rw-rw-r-- 1 jason jason 4.8K May  6 12:22 DB1_dataBU_20190506.sql

要么估计不正确,转储会丢失90%的内容/数据,要么我需要直接说明mysqldump的工作原理。

0 个答案:

没有答案