Re: After VACUUM, statistics become skewed

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert(dot)Farrugia(at)go(dot)com(dot)mt
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: After VACUUM, statistics become skewed
Date: 2003-05-21 16:51:06
Message-ID: 7858.1053535866@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Robert(dot)Farrugia(at)go(dot)com(dot)mt writes:
> Given a table around 4GB in size containing millions of records, before
> vacuuming the following query used the correct index
> (mo_200302_called_idx) which is built on answertime and callednumber_type.

Could we see EXPLAIN ANALYZE results for both the good plan and the bad
plan, for the same query? You're not giving us comparable results.

It would also be useful to show the pg_stats entries for the table.
I suspect that the planner is being fooled by some odd statistics of
your data, but we have not got any info here with which to speculate.

> Usually by dropping the table and reloading it from
> disk may solve the problem (it may take more than one try), but this is
> becoming unpractical due to the amount of data to restore each time.

You can get back to the un-analyzed state by deleting the rows in
pg_statistic for this table, viz
delete from pg_statistic where starelid = (select oid from
pg_class where relname = 'mobileorig_200302');
Grotty, but it sure beats dropping and reloading a big table.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Q 2003-05-21 18:07:20 Unsubscribe
Previous Message Robert.Farrugia 2003-05-21 15:00:21 After VACUUM, statistics become skewed