PostgreSQL 支持表(片段)的透明压缩吗?
我将在碎片化的 PostgreSQL 表(每天表)中存储大量数据(日志)。我想压缩其中一些以节省光盘空间,但我不想失去以通常方式查询它们的能力。
PostgreSQL 是否支持这种透明压缩?我在哪里可以阅读有关它的更多详细信息?我想这样的功能应该有一个众所周知的神奇名字。
I'm going to store large amount of data (logs) in fragmented PostgreSQL tables (table per day). I would like to compress some of them to save some space on my discs, but I don't want to lose the ability to query them in the usual manner.
Does PostgreSQL support such a transparent compression and where can I read about it in more detail? I think there should be some well-known magic name for such a feature.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,当它们超过一定大小时,PostgreSQL 会自动为您执行此操作。但压缩应用于每个单独的数据值 - 不是在整个表级别。这意味着如果您有十亿行非常窄,它们将不会被压缩。或者,如果您有很多列,每个列中只有一个很小的值,则它们不会被压缩。有关此方案的详细信息,请参见手册。
如果您在完整表级别需要它,解决方案是为那些要压缩的表创建一个表空间,并将其指向压缩文件系统。只要文件系统仍然遵循 fsync() 和标准 POSIX 语义,这应该是完全安全的。有关详细信息,请参阅手册。
Yes, PostgreSQL will do this automatically for you when they go above a certain size. Compression is applied at each individual data value though - not at the full table level. Meaning that if you have a billion rows that are very narrow, they won't get compressed. Or if you have very many columns each with only a small value in it, they won't get compressed. Details about this scheme in the manual.
If you need it on the full table level, a solution is to create a TABLESPACE for those tables that you want compressed, and point it to a compressed filesystem. As long as the filesystem still obeys fsync() and standard POSIX semantics, this should be perfectly safe. Details about this in the manual.
可能不是您想要的,但仍然有用的信息 - 第 53 章. 数据库物理存储< /a> 的精美手册。 TOAST 部分值得进一步关注。
Probably not what you have in mind but still useful info - Chapter 53. Database Physical Storage of the fine manual. The TOAST section warrants further attention.