Re: VACUUM touching file but not updating relation - Mailing list pgsql-general

From Simon Riggs
Subject Re: VACUUM touching file but not updating relation
Date
Msg-id CA+U5nMKbJUQjWhLm=nU8i92kUs3VguqbmdQbmr0VuPMWvN28hw@mail.gmail.com
Whole thread Raw
In response to Re: VACUUM touching file but not updating relation  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: VACUUM touching file but not updating relation  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Fri, Nov 18, 2011 at 2:47 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thom Brown <thom@linux.com> writes:
>>> On 11 November 2011 23:28, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>> I observe that _bt_delitems_vacuum() unconditionally dirties the page
>>>> and writes a WAL record, whether it has anything to do or not; and that
>>>> if XLogStandbyInfoActive() then btvacuumscan will indeed call it despite
>>>> there being (probably) nothing useful to do.  Seems like that could be
>>>> improved.  The comment explaining why it's necessary to do that doesn't
>>>> make any sense to me, either.
>
>>> Well the effect, in the single instances I've checked, is certainly
>>> more pronounced for hot_standby, but there still appears to be some
>>> occurrences for minimal wal_level too.
>
>> So would you say this is acceptable and normal activity, or is
>> something awry here?
>
> Well, it's expected given the current coding in the btree vacuum logic.
> It's not clear to me why it was written like that, though.

The code works as designed.

_bt_delitems_vacuum() is only ever called with nitems == 0 when it is
the last block of the relation with wal_level = hot standby

As discussed in the comments we must issue a WAL record for the last
block, whatever else has occurred.

So the correct number of WAL records is emitted and I see no bug there.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-general by date:

Previous
From: Simon Riggs
Date:
Subject: Re: VACUUM touching file but not updating relation
Next
From: Tom Lane
Date:
Subject: Re: VACUUM touching file but not updating relation