PostgreSQL 是否支持表(片段)的透明压缩?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1369864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:21:06  来源:igfitidea点击:

Does PostgreSQL support transparent compressing of tables (fragments)?

postgresqlcompressionstorage

提问by Prikrutil

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.

我将在碎片化的 PostgreSQL 表(每天表)中存储大量数据(日志)。我想压缩其中的一些以在我的光盘上节省一些空间,但我不想失去以通常方式查询它们的能力。

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.

PostgreSQL 是否支持这种透明压缩,我可以在哪里阅读更详细的信息?我认为这样的功能应该有一些众所周知的神奇名称。

回答by Magnus Hagander

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.

是的,当它们超过特定大小时,PostgreSQL 会自动为您执行此操作。虽然压缩应用于每个单独的数据值 - 而不是在完整的表级别。这意味着如果您有十亿行非常窄,它们将不会被压缩。或者,如果您有很多列,每个列中只有一个很小的值,则它们不会被压缩。手册中有关此方案的详细信息。

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.

如果您需要在完整的表级别上使用它,一个解决方案是为您想要压缩的那些表创建一个 TABLESPACE,并将其指向一个压缩的文件系统。只要文件系统仍然遵守 fsync() 和标准 POSIX 语义,这应该是完全安全的。手册中有关于这方面的详细信息。

回答by Milen A. Radev

Probably not what you have in mind but still useful info - Chapter 53. Database Physical Storageof the fine manual. The TOASTsection warrants further attention.

可能不是你想到的,但仍然是有用的信息 -第 53 章。数据库物理存储的精细手册。该TOAST部分值得进一步关注。