Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V70uy-00083e-DO for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Aug 2013 10:24:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V70ux-0007hs-TU for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Aug 2013 10:24:35 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V70ux-0007hg-7c for pgsql-bugs@postgresql.org; Wed, 07 Aug 2013 10:24:35 +0000 Received: from bln4.gameduell.de ([213.95.169.180]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V70ut-0000AU-4t for pgsql-bugs@postgresql.org; Wed, 07 Aug 2013 10:24:34 +0000 Received: from bln1.gameduell.de (smtp.gd [10.1.1.148]) by bln4.gameduell.de (Postfix) with SMTP id CEFB5E7 for ; Wed, 7 Aug 2013 12:24:28 +0200 (CEST) Received: (qmail 11576 invoked from network); 7 Aug 2013 12:24:28 +0200 Received: from unknown (HELO ?10.2.1.132?) (10.2.1.132) by mailer.gd with SMTP; 7 Aug 2013 12:24:28 +0200 Message-ID: <5202205C.8030904@sourcebase.org> Date: Wed, 07 Aug 2013 12:24:28 +0200 From: Sebastian Kornehl User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Reltuples/n_live_tup values wrong Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, I'm facing a problem which seems like a bug to me. I'm running: centos 5.9 postgresql92.x86_64 (9.2.4-1PGDG.rhel5) I have a table whith many inserts/deletes > select * from pg_stat_user_tables where schemaname = 'lobby' and > relname = 'lobby_player' order by n_live_tup desc; > relid | schemaname | relname | seq_scan | seq_tup_read | idx_scan | > idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | > n_live_tup | n_dead_tup | last_vacuum | last_autovacuum | last_analyze > | last_autoanalyze | vacuum_count | autovacuum_count | analyze_count | > autoanalyze_count > -------+------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+-------------------------------+------ > -------------------------+-------------------------------+-------------------------------+--------------+------------------+---------------+------------------- > 16594 | lobby | lobby_player | 231335 | 7156825 | 3726165 | 3334044 | > 277457 | 124 | 277380 | 118 | 608965 | 187 | 2013-08-07 > 11:38:08.877226+02 | 2013- 08-07 10:48:16.282828+02 | 2013-08-07 > 11:17:50.551531+02 | 2013-08-06 19:48:41.649425+02 | 8 | 25 | 4 | 24 > (1 row) > select reltuples from pg_class where relname = 'lobby_player'; > reltuples > ----------- > 608985 > (1 row) But my Problem is the following: > select count(*) from lobby_player; > count > ------- > 10 > (1 row) If I do an analyze, the stats change: > select relname, n_live_tup, n_dead_tup, last_vacuum, last_autovacuum > from pg_stat_user_tables where schemaname = 'lobby' and relname = > 'lobby_player' order by n_live_tup desc; > relname | n_live_tup | n_dead_tup | last_vacuum | last_autovacuum > --------------+------------+------------+-------------------------------+------------------------------- > lobby_player | 15 | 609186 | 2013-08-07 11:38:08.877226+02 | > 2013-08-07 10:48:16.282828+02 > (1 row) Reltuples stays at the 600k value, after another vacuum the tuples are live again. I already did a reindex table, dropped the index+pkey, vacuum full but it doesn't change anything. Another thing I see is: > \dt+ lobby_player > List of relations > Schema | Name | Type | Owner | Size | Description > --------+--------------+-------+-------+-------+------------- > lobby | lobby_player | table | adm | 46 MB | > (1 row) > select oid from pg_class where relname = 'lobby_player'; > oid > ------- > 16594 > (1 row) > postgres@database:~ # ls -alh 9.2/data/base/*/16594* > -rw------- 1 postgres postgres 0 Aug 7 11:34 9.2/data/base/16384/16594 So the 46MB are not there > vacuum ANALYZE VERBOSE lobby_player; > INFO: vacuuming "lobby.lobby_player" > INFO: index "lobby_player_pkey" now contains 609319 row versions in > 2348 pages > DETAIL: 0 index row versions were removed. > 0 index pages have been deleted, 0 are currently reusable. > CPU 0.00s/0.00u sec elapsed 8.03 sec. > INFO: index "idx_lobby_player_gtype_player_type" now contains 609319 > row versions in 1674 pages > DETAIL: 0 index row versions were removed. > 0 index pages have been deleted, 0 are currently reusable. > CPU 0.00s/0.00u sec elapsed 1.00 sec. > INFO: "lobby_player": found 0 removable, 609319 nonremovable row > versions in 5937 out of 5937 pages > DETAIL: 609299 dead row versions cannot be removed yet. > There were 0 unused item pointers. > 0 pages are entirely empty. > CPU 0.00s/0.00u sec elapsed 16.18 sec. > INFO: vacuuming "pg_toast.pg_toast_16594" > INFO: index "pg_toast_16594_index" now contains 0 row versions in 1 pages > DETAIL: 0 index row versions were removed. > 0 index pages have been deleted, 0 are currently reusable. > CPU 0.00s/0.00u sec elapsed 0.00 sec. > INFO: "pg_toast_16594": found 0 removable, 0 nonremovable row > versions in 0 out of 0 pages > DETAIL: 0 dead row versions cannot be removed yet. > There were 0 unused item pointers. > 0 pages are entirely empty. > CPU 0.00s/0.00u sec elapsed 0.00 sec. > INFO: analyzing "lobby.lobby_player" > INFO: "lobby_player": scanned 5937 of 5937 pages, containing 21 live > rows and 609302 dead rows; 21 rows in sample, 21 estimated total rows > VACUUM Thanks for any help! -Sebastian -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs