英文:
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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论