Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8FA44477088 for ; Mon, 6 Jan 2003 15:50:22 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 57D1A4768B5 for ; Mon, 6 Jan 2003 15:50:21 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 3BC7D43B048; Mon, 6 Jan 2003 15:50:21 -0500 (EST) From: Jeff Boes X-Newsgroups: comp.databases.postgresql.admin Subject: ANALYZE not working? Date: Mon, 06 Jan 2003 15:52:21 -0500 Organization: Nexcerpt, Inc. Lines: 72 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org User-Agent: Pan/0.11.4 (Unix) X-Comment-To: ALL To: pgsql-admin@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/41 X-Sequence-Number: 6883 At some point after we upgraded to Postgres 7.2 from 7.1, we noticed that VACUUM ANALYZE wasn't updating pg_class.reltuples. It only happened for systems where we'd upgraded; a fresh installation or a new database was not affected. So we started using # vacuum TABLENAME; analyze TABLENAME; where appropriate. Suddenly (like within the last week or so?), ANALYZE isn't working properly (it is recording pg_class.reltuples far lower than the actual row count). This is just way too weird: $ psql # select count(*) from stat_fetch; count -------- 143243 (1 row) (Big table, two indexes.) # analyze stat_fetch; ANALYZE (That should update all the stats, right?) # select relname, reltuples from pg_class # where relname = 'stat_fetch'; relname | reltuples ------------+----------- stat_fetch | 3419 (1 row) (Wha? Huh?) # vacuum stat_fetch; VACUUM (That should NOT impact the stats, right?) # select relname, reltuples from pg_class # where relname = 'stat_fetch'; relname | reltuples ------------+----------- stat_fetch | 179955 (1 row) (Hmm, a bit bigger this time?!? And why so different from the count(*)??) # analyze stat_fetch; ANALYZE (Just to make sure it's not a one-time thing) # select relname, reltuples from pg_class # where relname = 'stat_fetch'; relname | reltuples ------------+----------- stat_fetch | 3422 (1 row) (I give up, I need a strong beverage of some sort ...) -- Jeff Boes vox 616.226.9550 ext 24 Database Engineer fax 616.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ...Nexcerpt... Extend your Expertise