pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Litao Wu <litaowu@yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: reltuples after vacuum and analyze
Date: Tue, 25 Jan 2005 10:29:26 -0800 (PST)
Message-ID: <20050125182926.98344.qmail@web30309.mail.mud.yahoo.com> (raw)
In-Reply-To: <27553.1106612786@sss.pgh.pa.us>

Thanks,

Then how to explain relpages 
(size_kb in result returned)?

SELECT relname, relpages * 8 as size_kb,
relfilenode, reltuples
FROM pg_class c1
WHERE relkind = 'r'
AND relname = 'my_tab';
     relname      | size_kb | relfilenode | reltuples
------------------+---------+-------------+-----------
 my_tab           |   30088 |   266181583 |    165724
analyze my_tab;
     relname      | size_kb | relfilenode |  reltuples
------------------+---------+-------------+-------------
 my_tab           | 2023024 |   266181583 |
1.12323e+07
vacuum my_tab;
SELECT relname, relpages * 8 as size_kb,
relfilenode, reltuples
FROM pg_class c1
WHERE relkind = 'r'
AND relname = 'my_tab';
     relname      | size_kb | relfilenode | reltuples
------------------+---------+-------------+-----------
 my_tab           | 2038016 |   266181583 |    189165
(1 row)

--- Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Litao Wu <litaowu@yahoo.com> 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
> 



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250



view thread (7+ messages)  latest in thread

Message-ID: <20050125182926.98344.qmail@web30309.mail.mud.yahoo.com>
Permalink:  ../20050125182926.98344.qmail@web30309.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/20050125182926.98344.qmail@web30309.mail.mud.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: litaowu@yahoo.com, tgl@sss.pgh.pa.us
  Subject: Re: reltuples after vacuum and analyze
  In-Reply-To: <20050125182926.98344.qmail@web30309.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox