作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个关于 Postgres 自动真空/真空设置的问题。
我有一个包含 45 亿行的表,有一段时间进行了大量更新,导致大约 15 亿个死元组。此时 autovacuum 需要很长时间(几天)才能完成。
在查看 pg_stat_progress_vacuum View 时,我注意到:
max_dead_tuples = 178956970
导致多次索引重新扫描(index_vacuum_count)
maintenance_work_mem = 20GB
autovacuum_work_mem = -1
那么我错过了什么?为什么我的所有 1.5b 死元组都不能放入 max_dead_tuples 中,因为 20GB 应该提供足够的空间,为什么需要多次运行?
最佳答案
对于一个 VACUUM
中的死元组数量,硬编码限制为 1GB。循环,见 the source :
/*
* Return the maximum number of dead tuples we can record.
*/
static long
compute_max_dead_tuples(BlockNumber relblocks, bool useindex)
{
long maxtuples;
int vac_work_mem = IsAutoVacuumWorkerProcess() &&
autovacuum_work_mem != -1 ?
autovacuum_work_mem : maintenance_work_mem;
if (useindex)
{
maxtuples = MAXDEADTUPLES(vac_work_mem * 1024L);
maxtuples = Min(maxtuples, INT_MAX);
maxtuples = Min(maxtuples, MAXDEADTUPLES(MaxAllocSize));
/* curious coding here to ensure the multiplication can't overflow */
if ((BlockNumber) (maxtuples / LAZY_ALLOC_TUPLES) > relblocks)
maxtuples = relblocks * LAZY_ALLOC_TUPLES;
/* stay sane if small maintenance_work_mem */
maxtuples = Max(maxtuples, MaxHeapTuplesPerPage);
}
else
maxtuples = MaxHeapTuplesPerPage;
return maxtuples;
}
MaxAllocSize
在
src/include/utils/memutils.h
中定义作为
#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
您可以游说 pgsql-hackers 列表以增加限制。
关于postgresql - 在 Postgres 中加速 autovacuum,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66909708/
我和我的 friend 正在使用 turtle 开发 Python 游戏。我们的问题在定义 turtle 的部分。我们正在尝试加快每只 turtle 的速度,但当我们这样做时,默认速度运行。为什么会出
我是一名优秀的程序员,十分优秀!