暂无图片
postgresql怎么查询每天归档的日志量,有什么方便的sql吗?
我来答
分享
jieguo
2021-09-28
postgresql怎么查询每天归档的日志量,有什么方便的sql吗?

postgresql怎么查询每天归档的日志量,有什么方便的sql吗?

我来答
添加附件
收藏
分享
问题补充
2条回答
默认
最新
Lucifer三思而后行
暂无图片

归档每天产生一个日志文件夹,进入指定归档目录,执行 du -sh 查看当天归档量。

暂无图片 评论
暂无图片 有用 0
打赏 0
jieguo
题主
2021-09-28
有没有类似oracle视图可查询的?
wuc

pg_stat_file去分析下wal日志目录,例如:

with tmp_file as (
select to_char(date_trunc('day',(pg_stat_file(file)).modification),'yyyymmdd') as day_id,
date_part('hour',(pg_stat_file(t1.file)).modification) as last_update_time,
date_part('minute',(pg_stat_file(t1.file)).modification) as last_update_per_min
from (select dir||'/'||pg_ls_dir(t0.dir) as file,
pg_ls_dir(t0.dir) as file_ls
from ( select setting||'/pg_wal' as dir from pg_settings where name='data_directory'
) t0
) t1
where 1=1 and t1.file_ls not in ('archive_status','.history')
order by (pg_stat_file(file)).modification desc
)
select day_id as 日期,
last_update_time as 小时,
sum(case when last_update_per_min >=0 and last_update_per_min <=10 then 1 else 0 end) as 第0_10分钟,
sum(case when last_update_per_min >10 and last_update_per_min <=20 then 1 else 0 end) as 第10_20分钟,
sum(case when last_update_per_min >20 and last_update_per_min <=30 then 1 else 0 end) as 第20_30分钟,
sum(case when last_update_per_min >30 and last_update_per_min <=40 then 1 else 0 end) as 第30_40分钟,
sum(case when last_update_per_min >40 and last_update_per_min <=50 then 1 else 0 end) as 第40_50分钟,
sum(case when last_update_per_min >50 and last_update_per_min <=60 then 1 else 0 end) as 第50_60分钟
from tmp_file tf
where 1=1
group by day_id,last_update_time
order by day_id,last_update_time desc; 

暂无图片 评论
暂无图片 有用 2
打赏 0
回答交流
Markdown


请输入正文
提交
相关推荐
pg中索引损坏(有坏块),表还能否正常使用?
回答 4
可以正常使用但是可能会走全表扫影响效率rebuildindex锁表,DML和select都会被锁rebuildindexconcurrentlypostgresl12才的功能createindexco
pg_class中看不到oid字段,但是能用,请问怎么理解?
回答 2
看文档的话pg10应该是能直接看到oid这个列的而pg9.3之前的版本比如说9.2就没有你是pg10的话也许是psql的\d帮你隐藏了这个oid的列
PostgreSQL数据类型TEXT
回答 4
已采纳
你不用管你的字段类型吧,你存的是时间数据,直接转换成时间或字符类型存在oracle库里不行吗?
postgreSQL 慢日志怎么分析?
回答 1
pgbadger
目前postgreSQL的哪个版本最稳定?或者说推荐使用哪个版本?
回答 1
目前PostgreSQL的最新版本是13.0,它是一个非常稳定和成熟的版本。如果您需要使用最新的功能和特性,那么推荐使用13.0版本。但是,如果您的应用程序不需要最新的功能,或者您的应用程序已经使用了
pg生产都用什么高可用方案
回答 5
1、配置代理HAProxy,使用PgBouncer2、使用repmgr插件实现主从故障转移3、使用Patroni分布式架构实现高可用
postgresql :你们业务会大量放在存储过程中吗?
回答 1
已采纳
看开发团队风格,有的喜欢有的不喜欢。
developerworks上的文章怎么找
回答 2
https://developer.ibm.com/
为什么postgresql日志文件中shut down之后基本同一时刻又ready to accept connections?
回答 2
上面的日志都属于数据库启动日志,可以注意截图中两句话的谓词:was和is。was提示过去关闭数据库服务的时间,is是现在数据库服务启动完成,可以进行连接了。
在PostgresSQL中,以下哪个不是块头记录的信息?
回答 1
已采纳
A数据块的位置
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~