pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron Mayer <ron@intervideo.com>
To: Jeff Boes <jboes@nexcerpt.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: ANALYZE not working?
Date: Mon, 6 Jan 2003 14:09:47 -0800 (PST)
Message-ID: <Pine.LNX.4.33.0301061403570.1653-100000@ron> (raw)
In-Reply-To: <avcq6b$187s$1@news.hub.org>


On Mon, 6 Jan 2003, Jeff Boes wrote:
>
> [...] Suddenly [...] ANALYZE isn't working properly (it is recording
> pg_class.reltuples far lower than the actual row count).

I had the same problem recently...
  http://archives.postgresql.org/pgsql-bugs/2002-08/msg00015.php
where "vacuum analyze" and "vacuum; analyze;" were giving me
three orders of magnitude differences in estimates.

Apparently "analyze" is somewhat dependant on the order in which
rows had been inserted in the table; since it just does a (small)
random sample rather than a full table scan.

The thread there has some detailed explanation from Tom about the
underlying cause of the different results and how to diagnose it.


Short summary for me was that for a short term fix, I paid
the price for the slower "vacuum analzye" more frequently;
and later I re-ordered the whole table
  create table tmp_table as select * from my_table order by foo;
  drop table my_table;
  alter table tmp_table rename to my_table;
which made "analyze;" give good estimates again.

Hope this helps.
   Ron






view thread (3+ messages)

Message-ID: <Pine.LNX.4.33.0301061403570.1653-100000@ron>
Permalink:  ../Pine.LNX.4.33.0301061403570.1653-100000@ron/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0301061403570.1653-100000@ron

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: ron@intervideo.com, jboes@nexcerpt.com
  Subject: Re: ANALYZE not working?
  In-Reply-To: <Pine.LNX.4.33.0301061403570.1653-100000@ron>
  References: <avcq6b$187s$1@news.hub.org> <Pine.LNX.4.33.0301061403570.1653-100000@ron>

* 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