pg_stat_database的字段tup_returned,tup_fetched含义


--以前一直对tup_returned,tup_fetched的意思有疑惑,不知道两者之间的区别到底是什么,官网解释如下:
tup_returned:Number of rows returned by queries in this database
tup_fetched :Number of rows fetched by queries in this database


--查postgres数据库的基础数据如下
postgres=# select datname,pg_size_pretty(temp_bytes),temp_files,tup_returned,tup_fetched from pg_stat_database where datname = 'postgres';
 datname  | pg_size_pretty | temp_files | tup_returned | tup_fetched 
----------+----------------+------------+--------------+-------------
 postgres | 0 bytes        |          0 |      2703567 |       70611
(1 row)

--统计一个表的行数
postgres=# select count(*) from test_kenyon ;
 count 
-------
    23
(1 row)


--再次查看postgres数据库的统计,可以发现tup_fetched,是数据库最终呈现给用户的行数,tup_returned是数据库用户为呈现这些数据要返回给客户的端的行数
--听着有占绕,比如上例tup_fetched差值为1,说明count(*)之后数据库呈现给用户的行数为1,tup_returned的差值为24,说明数据库要返回count(*)的值要查询到满
postgres=# select datname,pg_size_pretty(temp_bytes),temp_files,tup_returned,tup_fetched from pg_stat_database where datname = 'postgres';
 datname  | pg_size_pretty | temp_files | tup_returned | tup_fetched 
----------+----------------+------------+--------------+-------------
 postgres | 0 bytes        |          0 |      2703591 |       70612
(1 row)

postgres=# select 2703591-2703567;
 ?column? 
----------
       24

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值