Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1libi0-00070S-Sf for pgsql-docs@arkaria.postgresql.org; Mon, 17 May 2021 11:46:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1libhy-0007DS-JL for pgsql-docs@arkaria.postgresql.org; Mon, 17 May 2021 11:46:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1libhy-0007CJ-D7 for pgsql-docs@lists.postgresql.org; Mon, 17 May 2021 11:46:50 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1libhs-0003Lc-NQ for pgsql-docs@lists.postgresql.org; Mon, 17 May 2021 11:46:49 +0000 Received: from hnk.local (p2388012-ipbf1027funabasi.chiba.ocn.ne.jp [118.6.6.12]) by oss.nttdata.com (Postfix) with ESMTPSA id BB2856033C; Mon, 17 May 2021 20:46:38 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at oss.nttdata.com Subject: Re: more detailed description of tup_returned and tup_fetched To: Masahiro Ikeda , pgsql-docs@lists.postgresql.org References: <9eeeccdb-5dd7-90f9-2807-a4b5d2b76ca3@oss.nttdata.com> <19f98fd2-c81b-f77f-d940-2816c565f850@oss.nttdata.com> From: Fujii Masao Message-ID: <03d26cbe-cce3-5cdf-89e6-df3769ff7728@oss.nttdata.com> Date: Mon, 17 May 2021 20:46:38 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021/05/17 18:58, Masahiro Ikeda wrote: > > > On 2021/05/17 15:32, Fujii Masao wrote: >> >> >> On 2021/05/14 17:00, Masahiro Ikeda wrote: >>> Hi, >>> >>> I worried the difference between "tup_returned" and "tup_fetched" in >>> pg_stat_database. I assumed that "tup_returned" means the number of tuples >>> that returned to clients. Of course, this is wrong. >> >> -       Number of rows returned by queries in this database >> +       Number of live rows returned by sequential scans of queries in this >> database >> >> -       Number of rows fetched by queries in this database >> +       Number of live rows fetched by index scan of queries in this database >> >> I found the following comments in pgstat.h. So maybe even these >> new descriptions are incorrect? >> >>  * Note: for a table, tuples_returned is the number of tuples successfully >>  * fetched by heap_getnext, while tuples_fetched is the number of tuples >>  * successfully fetched by heap_fetch under the control of bitmap indexscans. >>  * For an index, tuples_returned is the number of index entries returned by >>  * the index AM, while tuples_fetched is the number of tuples successfully >>  * fetched by heap_fetch under the control of simple indexscans for this index. > > Oh, Thanks! > > I updated the sentences using the descriptions of > "pg_stat_all_tables.seq_tup_read", "pg_stat_all_tables.idx_tup_fetch", and > "pg_stat_all_index.idx_tup_read". > > - Number of rows returned by queries in this database > + Number of rows returned by queries in this database. The rows > correspond to the live rows fetched by sequential scans and index entries > returned by scans on indexes This is still not correct because this counter is incremented even when other scan like TidScan happens? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION