VACUUM 只扫描一小部分页面?

问题描述 投票:0回答:1

我尝试清理一个 790 GB 大小的表:

wento=# VACUUM (VERBOSE, ANALYZE) public.wento;  
INFO:  vacuuming "wento.public.wento"  
INFO:  finished vacuuming "wento.public.wento": index scans: 0  
pages: 0 removed, 19249 remain, 727 scanned (3.78% of total)  
tuples: 0 removed, 2543622 remain, 5034 are dead but not yet removable  
removable cutoff: 2797274, which was 18769 XIDs old when operation ended  
index scan bypassed: 160 pages from table (0.83% of total) have 638 dead item identifiers  
avg read rate: 98.195 MB/s, avg write rate: 23.735 MB/s  
buffer usage: 622 hits, 724 misses, 175 dirtied  
WAL usage: 175 records, 175 full page images, 1372087 bytes  
system usage: CPU: user: 0.00 s, system: 0.01 s, elapsed: 0.05 s  
INFO:  vacuuming "wento.pg_toast.pg_toast_19276"  
^C
Cancel request sent  
ERROR:  canceling statement due to user request  
CONTEXT:  while scanning block 102413194 of relation "pg_toast.pg_toast_19276"

我知道死元组没有被删除,因为有一个长时间运行的事务。
但我想知道为什么它只扫描了 727 页(占总数的 3.78%)?

postgresql vacuum
1个回答
0
投票

VACUUM
通常只扫描自上次迭代以来已接收写入的页面。 说明书:

VACUUM
使用可见性图来确定必须扫描表格的哪些页面。通常,它会跳过没有任何死行版本的页面,即使这些页面可能仍然具有具有旧
XID
值的行版本。

手册中有更多精美印刷。

© www.soinside.com 2019 - 2024. All rights reserved.