Re: BUG #7853: Incorrect statistics in table with many dead rows.

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: "jimbob(at)seagate(dot)com" <jimbob(at)seagate(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #7853: Incorrect statistics in table with many dead rows.
Date: 2013-02-05 22:00:46
Message-ID: 1360101646.24672.YahooMailNeo@web162901.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"jimbob(at)seagate(dot)com" <jimbob(at)seagate(dot)com> wrote:

> INFO:  analyzing "public.stream_file"
> INFO:  "stream_file": scanned 30000 of 2123642 pages, containing
> 184517 live rows and 2115512 dead rows; 30000 rows in sample,
> 158702435 estimated total rows

184517 live rows in 30000 randomly sampled pages out of 2123642
total pages, means that the statistics predict that a select
count(*) will find about  13 million live rows to count.

> After "analyze verbose", the table shows 158 million rows. A
> select count(1) yields 13.8 million rows.

OK, the estimate was 13 million and there were actually 13.8
million, but it is a random sample used to generate estimates.
That seems worse than average, but close enough to be useful.
The 158.7 million total rows includes dead rows, which must be
visited to determine visibility, but will not be counted because
they are not visible to the counting transaction.  Having over 90%
of your table filled with dead rows is a bad situation to be in,
from a performance standpoint.  You should use aggressive
maintenance (like VACUUM FULL or CLUSTER) to fix the existing
extreme bloat, and then review your autovacuum settings and overall
vacuum regimen to prevent future bloat.

This does not look like a bug from the information provided so far.

-Kevin

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message James R Skaggs 2013-02-05 22:43:35 Re: BUG #7853: Incorrect statistics in table with many dead rows.
Previous Message Ivano Luberti 2013-02-05 20:42:07 Re: BUG #7851: Installer crash with message: An error occured executing the Microsoft VC++ runtimeinstaller