压缩存储在mysql中的数据
我们将完整的 html 页面存储在表中名为“conteny”的字段中。现在这个表就像一个档案,我们很少使用它。 “内容”字段现在的类型为“长文本”,我想知道哪种是我们压缩和保留该表数据的最佳方式,因为它占用了许多 GB 的空间。
我尝试简单地在 php 的内容字段上使用 gzcompress 函数,但这不起作用。eg
$content = gzcompress($content,9);
也尝试过这个,但不起作用:
update posts_content set content = COMPRESS(content)
任何想法最好的方法是什么以及如何做?
这里的另一个问题 Is mysql 自动压缩数据库吗? 谈论 INNODB 但我们使用MYISAM 并可以迁移到 INNODB 作为最后的手段。
谢谢你
We store full html pages in our table in a field called 'conteny'. Now this table is like an archive and we would be rarely using it. The 'content' field is of type 'longtext' right now and I would like to know which is the best way we could compress and keep this table's data as its taking many gbs of space.
I tried simply using the gzcompress function on the content field in php but that did not work.e.g.
$content = gzcompress($content,9);
Also tried this but does not work:
update posts_content set content = COMPRESS(content)
Any ideas whats the best way to do it and how?
Another question here Is mysql automatically compressing the database? talks about INNODB but we use MYISAM and could move to INNODB as a final resort.
Thanking you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用压缩时,结果是二进制而不是文本。您不应尝试将结果存储在文本列中。
BLOB
列应与gzcompress
方法配合使用。When using compression the result is binary not text. You shouldn't try to store the result in a text column. A
BLOB
column should work with thegzcompress
method.