压缩存储在mysql中的数据

发布于 2025-01-01 17:01:28 字数 563 浏览 4 评论 0原文

我们将完整的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⒈起吃苦の倖褔 2025-01-08 17:01:28

使用压缩时,结果是二进制而不是文本。您不应尝试将结果存储在文本列中。 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 the gzcompress method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文