Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boszI-0005cm-Il for pgsql-admin@arkaria.postgresql.org; Tue, 27 Sep 2016 14:04:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1boszI-0006Wo-5S for pgsql-admin@arkaria.postgresql.org; Tue, 27 Sep 2016 14:04:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bosxa-0003yA-BS for pgsql-admin@postgresql.org; Tue, 27 Sep 2016 14:02:14 +0000 Received: from nm7-vm1.bullet.mail.ir2.yahoo.com ([212.82.96.126]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bosxU-0002kJ-Iy for pgsql-admin@postgresql.org; Tue, 27 Sep 2016 14:02:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1474984925; bh=LmySefBWp6Kp0RaSOouMJzintp3qasspISOdR/Aoc+A=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=B4j6EEUhdHZKaVYFYTTg+l11eFCe36qt6/tiY9uRyp5yYcidAXZd3mN7OO38sZ6svfhLc4bqudW4yfQ7bVXhlxZFqoPl2f2hLhkzxMjlQrju0YHKVjERpYBbkI8bbF9ubIu2Dx5YkwygqzUY46YvaqQeXitbmN7ZvKhW/AZctKnp5/0O3tYpcRO5oTB5wuR8ElgEHxlbeMeZAeX0fZD8wgIslFfLckSQCV54/wZlyFdE86dtdFTisFFJFMrlt8IjQgL82lZjH5r+UXikDLGcDaabOTLhHxE6WR/iaMpR9MTLdc8AFeOWj/xVEEtjbPyj2QEtlTog3Y0TXeYUjY0mEg== Received: from [212.82.98.57] by nm7.bullet.mail.ir2.yahoo.com with NNFMP; 27 Sep 2016 14:02:05 -0000 Received: from [212.82.98.109] by tm10.bullet.mail.ir2.yahoo.com with NNFMP; 27 Sep 2016 14:02:05 -0000 Received: from [127.0.0.1] by omp1046.mail.ir2.yahoo.com with NNFMP; 27 Sep 2016 14:02:05 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 470375.14692.bm@omp1046.mail.ir2.yahoo.com X-YMail-OSG: aEWwHCMVM1kBo_ubYP8n7FyxpMfLgKYBdWxe6o3cfZWQorDBN2Hl4S0kqYeMhsx ZBruGd7ZcDUjWVCaEx06kLTyXuLBiyRPvLqciKtRiOpNt1_s1g5GC.WiVKl.xzVsjJxOqTQt9YnY sXP1QNJQWeIUteJ3nxr8VYktn7LcuJsevi8qsHBvSnTAX3.NBoMlWP1c0W8BABJXT7earTiBSpTI 2irXGPLnvNCS1r_eMaECtPEElyfnT18dBgTrKOdPzrt.2jOmxeS7rVsLoZshAoWj9lpu37eFLlPn _RQkFFdjh3MBbaAzd2nmaRYYxqFMgrtqIB5iyZSxKBRsRpOjzaGCX_isPPc.DYlpRvdTj.BF0JAG vxOtcR9VxkNCXoRJo.yefAAU5D0IrMms3BZ3pIDmcmtfHYOoTK11z6A_wxxEfZLJIv.14wbyws8I yzdTgIjRDqaaCLCNYRQUB2kMSqDxO9_lsMMDLXemIROWSYn3FV8a_uc.Hh90nM_H6zRPB4r42V3B Q7BXNjzow77v5os7p_xDkdHlSrRmQfQ-- Received: from jws11196.mail.ir2.yahoo.com by sendmailws163.mail.ir2.yahoo.com; Tue, 27 Sep 2016 14:02:04 +0000; 1474984924.885 Date: Tue, 27 Sep 2016 14:01:53 +0000 (UTC) From: Glyn Astill Reply-To: Glyn Astill To: Thomas SIMON , "pgsql-admin@postgresql.org" Message-ID: <1136485488.10643672.1474984913094@mail.yahoo.com> In-Reply-To: References: Subject: Re: Wrong stat on pg_stat_user_tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Length: 1502 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org > From: Thomas SIMON >To: "pgsql-admin@postgresql.org" >Sent: Tuesday, 27 September 2016, 9:20 >Subject: [ADMIN] Wrong stat on pg_stat_user_tables > > >Hi all, > >I have strange behavior with a stat of pg_stat_user_tables (explained >below), where number of live tuples is not the real number at all. (25M >vs 111M) > > > - select n_live_tup, last_autoanalyze from pg_stat_user_tables where >relname = 'items' > >n_live_tup : 111 191 791 >last_autoanalyze : 2016-09-27 04:03:35.09233+02 > > > - select count (1) from items; > count >---------- > 25307071 > > >I've comparated my 10 biggest tables, only this table gave me wrong results. > >Does anyone have an idea about it ? > Do you have any long running transactions? The value returned by n_live_tup is an estimate of all the live rows in the table, vs the value you see from count is the number rows visible to the current transaction. How long between sending the email and running the queries? What output do you see if you analyze the table? And what pg version is this? I think (I may be wrong) the value you see in pg_stat_user_tables is only an estimate based on a sample of tuples per page in the table, so if you've an uneven distribution of live rows you could see an incorrect value. What do the planner stats show you? Try: select reltuples::integer from pg_class where oid = 'items'::regclass; You might get a better response from the pgsql-general list. Glyn -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin