postgresql - visibility map: all visible pages
问题描述
The relallvisible field in pg_class view display the Number of pages that are marked all-visible in the table's visibility map.
When I try this example:
INSERT INTO foo (x) SELECT n FROM generate_series(1, 10000000) as n;
analyze table foo;
select nspname, relpages, reltuples, relallvisible, relfrozenxid, relminmxidfrom pg_class as c
join pg_namespace as ns on c.relnamespace = ns.oid
where relname = 'foo';
nspname | relpages | reltuples | relallvisible | relfrozenxid | relminmxid
---------+----------+-------------+---------------+--------------+------------
public | 44248 | 9.99998e+06 | 0 | 60995 | 1
(1 row)
Why is relallvisible field equal to 0 and not equal to the total number of pages that is 44248?
解决方案
因为VACUUM
从来没有在桌子上跑过。该命令构建并维护可见性地图。
您可能使用的是 PostgreSQL v12 或更低版本,并且该表没有收到足够的更新或删除来触发 autovacuum。如果您的用例涉及仅插入表,请升级 - 从 v13 开始,autovacuum 也将在仅插入表上运行。
推荐阅读
- mysql - 无法从 Node.js 连接到 MySql 服务器
- python - 如何比较python列表中的两个字典?
- java - 如何使用通过 Class.forName(String) 获得的类的方法?
- c++ - 检查字符串是否包含有效的后缀表达式
- typescript - 用于检查 typeof 的 keyof 原型的静态泛型函数...?
- android - 如何在同一个 kotlin-multiplatform 项目中设置 android、ios 和 kotlin-frontend?
- arduino - 如何使用 Arduino Mega 和 USB Host shield 从/向连接的设备读取/写入十六进制数据?
- swift - 键入时如何刷新 UISearchBar 搜索结果而无需按“搜索”按钮?有什么本土方法吗?
- xaml - 背景图像在 Emulator 和 Real Device Andriod 9.0 上显示,但在 8.1 及更低版本上不显示
- r - `devtools::test()`、`RNGversion` 和 `sample` 产生不同的结果