Re: row-attribute in EXPLAIN-output doesn't match count(*)

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: row-attribute in EXPLAIN-output doesn't match count(*)
Date: 2005-04-14 17:10:12
Message-ID: 20050414171012.GA9027@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Apr 14, 2005 at 06:38:14PM +0200, Andreas Joseph Krogh wrote:
> Hi everybody, I have table which inly has 298 rows in it, but EXPLAIN ANALYZE
> shows that PG thinks it has as much as 160057 rows AFAICT from the
> EXPLAIN-output.

It does have 160057 rows:

> INFO: vacuuming "public.onp_web_index"
> INFO: "onp_web_index": found 0 removable, 160057 nonremovable row versions in
> 206940 pages
> DETAIL: 159759 dead row versions cannot be removed yet.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You no doubt have a long-running transaction keeping the rows from
being recovered. Look for "idle in transaction" as a first guess.

> DETAIL: 160057 index row versions were removed.
> 0 index pages have been deleted, 0 are currently reusable.
> CPU 2.40s/0.92u sec elapsed 286.41 sec.
>
> Here it says that it removed 160057 rows, doesn't it?

No; that's the index row versions.

> Is this normal, shall I just overlook the "rows=160057" output from EXPLAIN,
> or is something wrong?
> What does the line "DETAIL: 159759 dead row versions cannot be removed yet."
> mean?

It means that those rows were marked invalidated after some existing
transaction started.

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
The plural of anecdote is not data.
--Roger Brinner

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2005-04-14 17:12:54 Re: row-attribute in EXPLAIN-output doesn't match count(*)
Previous Message PFC 2005-04-14 17:08:53 Re: Very low performance on table with only 298 rows