--以前一直对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
pg_stat_database的字段tup_returned,tup_fetched含义
最新推荐文章于 2024-07-03 07:30:00 发布