X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B96F63A4B4E for ; Tue, 25 Jan 2005 00:26:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41151-05 for ; Tue, 25 Jan 2005 00:26:26 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3F43C3A4A00 for ; Tue, 25 Jan 2005 00:26:26 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j0P0QQNe027554; Mon, 24 Jan 2005 19:26:27 -0500 (EST) To: Litao Wu Cc: pgsql-performance@postgresql.org Subject: Re: reltuples after vacuum and analyze In-reply-to: <20050124230242.18329.qmail@web30304.mail.mud.yahoo.com> References: <20050124230242.18329.qmail@web30304.mail.mud.yahoo.com> Comments: In-reply-to Litao Wu message dated "Mon, 24 Jan 2005 15:02:42 -0800" Date: Mon, 24 Jan 2005 19:26:26 -0500 Message-ID: <27553.1106612786@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/447 X-Sequence-Number: 10137 Litao Wu writes: > I noticed that reltuples are way off if > I vacuum the table and analyze the table. > And the data (296901) after vacuum seems > accurate while > the reltuples (1.90744e+06) > after anlayze is too wrong. VACUUM derives an exact count because it scans the whole table. ANALYZE samples just a subset of the table and extrapolates. It would appear that you've got radically different tuple densities in different parts of the table, and that's confusing ANALYZE. > My PG version is 7.3.2 (I know it is old). 8.0's ANALYZE uses a new sampling method that we think is less prone to this error, though of course any sampling method will fail some of the time. regards, tom lane