简体   繁体   English

SQL数据库导出大小不同

[英]SQL database export different size

I have an SQL database that is reported as being 40Mb in size when I look in cPanel. 我有一个SQL数据库,当我在cPanel中查看时,据报告大小为40Mb。 If I try and export the database using PHPMyAdmin, the export file is only 900Kb in size. 如果我尝试使用PHPMyAdmin导出数据库,则导出文件的大小仅为900Kb。

The strange thing is, if I import this file into a clean database then everything does appear to be there. 奇怪的是,如果我将此文件导入到一个干净的数据库中,那么一切似乎都在那里。

Anyone any ideas what could be causing this size issue? 任何人有什么想法可能导致此大小问题? Maybe it is just being incorrectly reported? 也许只是被错误地报告了?

That's because the database and the export are two completely different things. 这是因为数据库和导出是完全不同的两件事。

The export contains only raw data and table structure, while the database itself also contains extra data that is used for indexes. 导出仅包含原始数据和表结构,而数据库本身还包含用于索引的额外数据。 Apart from that, the format in which the data is stored also doesn't have to be the same. 除此之外,存储数据的格式也不必相同。 An export is probably optimized for either size or recoverability (or both), while the data in the production database is optimized for speed. 导出可能针对大小或可恢复性(或两者)进行了优化,而生产数据库中的数据则针对速度进行了优化。

It's hard to say, what is really causing this without having a look onto your schema. 很难说,到底是什么导致了这种现象,而无需了解您的模式。 owever, in most cases there a indizies inside your database which are consuming place as well as some more meta data per row. 但是,在大多数情况下,数据库中有很多消耗地方的索引以及每行更多的元数据。 Also depending on your engine, that data is stored in different ways and maybe reserving a lot of (at the moment) unneeded place for future, easier allocation. 同样,取决于您的引擎,该数据以不同的方式存储,并且可能会保留大量(当前)不需要的位置,以便将来进行更轻松的分配。 Another possibility could be, that you have exported the database compress -- there is an option for doing this in phpmyadmin. 另一种可能是,您已经导出了数据库压缩文件-phpmyadmin中提供了执行此操作的选项。

So many reasons ;) 这么多的原因;)

The two answers prior to mine are pretty good, but I have a bit to add. 我之前提出的两个答案相当不错,但我还有一点要补充。 Depending how cPanel is computing the space, there's a very simple explanation. 根据cPanel如何计算空间,有一个非常简单的解释。 Basically, certain table types don't reclaim disk space after your delete records. 基本上,某些表类型在删除记录后不会回收磁盘空间。 If, at one time, you stored 40Mb worth of data, then dropped a lot of it, that's a very reasonable cause for you to see it reported that the database still takes up 40Mb of space on disk. 如果一次存储了40Mb的数据,然后丢弃了很多数据,那是非常合理的原因,您可以看到它报告数据库仍然占用40Mb的磁盘空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM