匿名用户pg中怎么查询某些表在内存中的数据块的数量
怎么查询表在内存中的数据块的数量,效果如下:
relname,buffers
t1 ,2
t3,5
我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
墨值悬赏
匿名用户怎么查询表在内存中的数据块的数量,效果如下:
relname,buffers
t1 ,2
t3,5
select c.relname,count(*) as buffers from pg_buffercache b inner join pg_class c on b.relfilenode = pg_relation_filenode(c.oid) and b.reldatabase in (0,(select oid from pg_database where datname = current_database())) group by c.relname order by 2 desc;
亲测可用

如果报错:ERROR: relation "pg_buffercache" does not exist
解决办法:\c DB名
CREATE EXTENSION IF NOT EXISTS pg_buffercache;
然后重新执行语句即可
评论
有用 0
墨值悬赏