是否可以按表来确定Postgres每秒的写入率?

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

在PostgreSQL中,是否可以得到对表的写入量的近似值作为时间的衡量标准?

具体来说,我正在寻找一个对给定表的 "写秒 "的近似值。 我知道我可以从统计收集器中得到总的写入次数(插入、更新、删除),但是没有明确定义统计的 "开始 "时间,因此我无法确定一个速率。

有没有其他的表可以让我应用来进行这种计算?

SELECT relname, idx_tup_fetch + seq_tup_read as TotalReads,
    n_tup_ins + n_tup_upd + n_tup_del as TotalWrites, 
-- (n_tup_ins + n_tup_upd + n_tup_del) / magical_seconds_column_that_doesnt_exist as WritesPerSecond
    *
from pg_stat_all_tables
order by totalwrites desc
postgresql performance statistics
1个回答
1
投票

PostgreSQL本身没有这样的功能。你必须定期对统计表进行快照,然后自己计算数值。

请注意,如果使用 track_io_timing = on,你还会得到IO统计数据。

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