Postgresql – 如何找到表中的压缩字段?

huangapple go评论63阅读模式
英文:

Postgresql - How do I find compressed fields in a table?

问题

PostgreSQL 使用不同的存储技术来处理字段值。如果值变得很大(例如,长文本),PostgreSQL 最终会应用压缩和/或 TOAST 值。

我如何找出表中哪些字段已被压缩?

(背景信息:我有一个数据库,其中在某些列中存储了小的 BLOBs,我想找出其中有多少已经被压缩 - 如果几乎没有使用压缩,我想将其关闭,这样 PostgreSQL 不会浪费 CPU 循环尝试压缩)

英文:

Postgresql uses different storage techniques for field values. If values become large (e.g. are long texts), Postgresql will eventually apply compression and/or TOAST the values.

How do I find out which fields in a table are compressed?

(Backgound: I have database that stores tiny BLOBs in a some columns and I want to find out how much of it is compressed - if compression is hardly used, I want to turn it off, so Postgres won't waste CPU cycles on trying)

答案1

得分: 1

Starting in v14, there is the function pg_column_compression.

select pg_column_compression(colname), count(*) from tablename group by 1;

英文:

Starting in v14, there is the function pg_column_compression.

select pg_column_compression(colname),count(*) from tablename group by 1;

huangapple
  • 本文由 发表于 2023年2月19日 00:29:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75494735.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定