public inbox for [email protected]  
help / color / mirror / Atom feed
From: David Rowley <[email protected]>
To: Nathan Bossart <[email protected]>
Cc: Sami Imseih <[email protected]>
Cc: Robert Haas <[email protected]>
Cc: Jeremy Schneider <[email protected]>
Cc: [email protected]
Subject: Re: another autovacuum scheduling thread
Date: Sun, 26 Oct 2025 14:25:48 +1300
Message-ID: <CAApHDvoM5MEHHBc0TNdrzkpq39WdEHSZhdWrtnx9zOWNXTSFGw@mail.gmail.com> (raw)
In-Reply-To: <aPuWev3D9M4iGCUt@nathan>
References: <aPklC5V61VcTu7IP@nathan>
	<aPkpSXHB66islP3h@nathan>
	<CAApHDvqobtKMwJbhKB_c=3-TM=TgS3bcuvzcWMm3ee1c0mz9hw@mail.gmail.com>
	<aPkz9grlBAJRXrbe@nathan>
	<CAA5RZ0vSPqd5vP4-17E6QELRgQzaoKChgp5TDPK9GhZEK=0Gjg@mail.gmail.com>
	<aPp4VyLo2Zqk7oCV@nathan>
	<CAA5RZ0sfQ-VSCSafsrvyJ7wsW1utLwtPVJ5N6hB0726BGRDrgQ@mail.gmail.com>
	<CAApHDvpxE8ci83d02dRE3-fMetb4Dc89-80FrjkGDz2q+ByJog@mail.gmail.com>
	<CAA5RZ0upTpKqgrdNfMSX7UJdjx=+=CsQ6Xct+vcCZPvUVhdZvw@mail.gmail.com>
	<CAApHDvp1=FOs6GneTzLSCHnCmC7z1_80=U3M=CKd82-pwS3YHg@mail.gmail.com>
	<aPuWev3D9M4iGCUt@nathan>

On Sat, 25 Oct 2025 at 04:08, Nathan Bossart <[email protected]> wrote:
> Here is an updated patch based on the latest discussion.

Thanks. I've just had a look at it. A few comments and questions.

1) The subtraction here looks back to front:

+ xid_age = TransactionIdIsNormal(relfrozenxid) ? relfrozenxid - recentXid : 0;
+ mxid_age = MultiXactIdIsValid(relminmxid) ? relminmxid - recentMulti : 0;

2) Would it be better to move all the code that sets the xid_score and
mxid_score to under an "if (force_vacuum)"? Those two variables could
be declared in there too.

3) Could the following be refactored a bit so we only check the "relid
!= StatisticRelationId" condition once?

+ if (relid != StatisticRelationId &&
+ classForm->relkind != RELKIND_TOASTVALUE)

Something like:

/* ANALYZE refuses to work with pg_statistic and we don't analyze
toast tables */
if (anltuples > anlthresh && relid != StatisticRelationId &&
    classForm->relkind != RELKIND_TOASTVALUE)
{
    *doanalyze = true;
    // calc analyze score and Max with *score
}
else
  *doanalyze = false;

then delete:

/* ANALYZE refuses to work with pg_statistic */
if (relid == StatisticRelationId)
    *doanalyze = false;

4) Should these be TransactionIds?

+ uint32 xid_age;
+ uint32 mxid_age;

5) Instead of:

+ double score = 0.0;

Is it better to zero the score inside relation_needs_vacanalyze() so
it works the same as the other output parameters?

David





view thread (143+ messages)  latest in thread

reply

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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: another autovacuum scheduling thread
  In-Reply-To: <CAApHDvoM5MEHHBc0TNdrzkpq39WdEHSZhdWrtnx9zOWNXTSFGw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox