From: Tom Lane <tgl@sss.pgh.pa.us>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: Matthew T. O'Connor <matthew@zeut.net>
Cc: pgsql-hackers@postgreSQL.org, Otto Blomqvist <o.blomqvist@secomintl.com>
Cc: pgsql-performance@postgreSQL.org
Subject: Re: lazy_update_relstats considered harmful (was Re: [PERFORM] pg_autovacuum not having enough suction ?)
Date: Fri, 25 Mar 2005 17:35:58 -0500
Message-ID: <14073.1111790158@sss.pgh.pa.us> (raw)
In-Reply-To: <1111789223.11750.839.camel@localhost.localdomain>
References: <d1v0a7$iau$1@news.hub.org>
<42430FA0.9080204@zeut.net>
<002b01c530c5$ad5a1620$e602a8c0@blomqvist>
<42435408.30303@zeut.net>
<00f201c53168$96903480$e602a8c0@blomqvist>
<42446A66.6010504@zeut.net>
<11991.1111780527@sss.pgh.pa.us>
<12121.1111782169@sss.pgh.pa.us>
<1111789223.11750.839.camel@localhost.localdomain>
Simon Riggs <simon@2ndquadrant.com> writes:
> On Fri, 2005-03-25 at 15:22 -0500, Tom Lane wrote:
>> 2. Dead tuples don't have that much influence on scan costs either, at
>> least not once they are marked as known-dead. Certainly they shouldn't
>> be charged at full freight.
> Yes, minor additional CPU time, but the main issue is when the dead
> tuples force additional I/O.
I/O costs are mostly estimated off relpages, though, not reltuples.
The only time you really pay through the nose for a dead tuple is when
an indexscan visits it, but with the known-dead marking we now do in
btree indexes, I'm pretty sure that path is seldom taken.
>> It's possible that there'd be some value in adding a column to pg_class
>> to record dead tuple count, but given what we have now, the calculation
>> in lazy_update_relstats is totally wrong.
> Yes, thats the way. We can record the (averaged?) dead tuple count, but
> also record the actual row count in reltuples.
What I'd be inclined to record is the actual number of dead rows removed
by the most recent VACUUM. Any math on that is best done in the
planner, since we can change the logic more easily than the database
contents. It'd probably be reasonable to take half of that number as
the estimate of the average number of dead tuples.
But in any case, that's for the future; we can't have it in 8.0.*, and
right at the moment I'm focusing on what to push out for 8.0.2.
> We definitely need to record the physical and logical tuple counts,
> since each of them have different contributions to run-times.
There isn't any difference, if you are talking about fully dead tuples.
It would be possible for VACUUM to also count the number of
not-committed-but-not-removable tuples (ie, new from still-open
transactions, plus dead-but-still-visible-to-somebody), but I'm not sure
that it would be useful to do so, because that sort of count is hugely
transient. The stat would be irrelevant moments after it was taken.
regards, tom lane
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: tgl@sss.pgh.pa.us, simon@2ndquadrant.com, matthew@zeut.net, o.blomqvist@secomintl.com
Subject: Re: lazy_update_relstats considered harmful (was Re: [PERFORM] pg_autovacuum not having enough suction ?)
In-Reply-To: <14073.1111790158@sss.pgh.pa.us>
* 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