Re: [HACKERS] Autovacuum loose ends

Lists: pgsql-hackerspgsql-patches
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Autovacuum loose ends
Date: 2005-07-14 14:52:56
Message-ID: 18801.1121352776@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

I've applied Alvaro's latest integrated-autovacuum patch. There are
still a number of loose ends to be dealt with before beta, though:

* Not all the functionality of the current contrib code seems to have
made it in. In particular I noted the "sleep scaling factor" is
missing, as well as the options to use nondefault vacuum_cost_delay
settings. (I'm not sure how important the sleep scale factor is,
but the vacuum cost options seem pretty critical for practical use.)
There may be other stuff to move over; Matthew or someone more familiar
than I with the contrib version needs to take a look. (I have refrained
from removing the contrib module until we're sure we have extracted
everything from it.)

* The code does not make a provision to ignore temporary tables.
Although vacuum.c and analyze.c will disregard the request to touch
such tables, it'd probably be better to recognize the situation further
upstream. In particular it seems that autovacuum will continually throw
ANALYZE requests for a temp table due to lack of stats.

* ANALYZE also refuses to do anything with pg_statistic itself, which
is another case that may need special treatment to avoid useless cycles.

* For that matter I'm unconvinced that it's a good idea to try to force
the pgstat DB to pick up every table in every database. If there's no
entry it's because the table is not getting modified, and therefore it
seems to me that we can just leave well enough alone. The code really
is not very good about doing nothing where nothing is called for ;-)

* The code ignores datallowconn and therefore will periodically vacuum
template0. I've got mixed emotions about this --- it could save
someone's bacon if they failed to properly VACUUM FREEZE a template
database, but in 99.99% of installations it's just wasted cycles.
Maybe it'd make sense to perform XID-wraparound-prevention vacuuming,
but not anything more, in a template DB. Thoughts?

* Or actually, it would vacuum template0, except that since no regular
backend ever connects to template0, there will be no stats DB entry for
it and so the loop in AutoVacMain will ignore it. This is definitely
BAD as it means that a database that's not been touched since postmaster
start will never be vacuumed, not even for XID wraparound prevention.
That test needs to be weakened.

* I'm still pretty concerned about the handling of shared catalogs.
AFAICS the current pgstats infrastructure simply gets this wrong,
meaning that shared catalogs will not get adequate vacuuming. We need
to fix that.

* As Alvaro noted, the default parameter settings need a lookover.
What is in the patch is not what was the default in the contrib module,
but the contrib defaults seem awfully passive.

* The documentation badly needs work. I committed some minimal
additions to runtime.sgml and catalogs.sgml, but the chapter about
routine maintenance needs a section added about how to use autovac.

regards, tom lane


From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 16:57:39
Message-ID: 42D69983.4020908@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

This is great news! I will do what I can to continue improving the code
and address these concerns as best I can. Many of the items below will
need to be addressed by Alvaro, but I will comment where I think I have
something useful to say :-)

Tom Lane wrote:

>I've applied Alvaro's latest integrated-autovacuum patch. There are
>still a number of loose ends to be dealt with before beta, though:
>
>* Not all the functionality of the current contrib code seems to have
>made it in. In particular I noted the "sleep scaling factor" is
>missing, as well as the options to use nondefault vacuum_cost_delay
>settings. (I'm not sure how important the sleep scale factor is,
>but the vacuum cost options seem pretty critical for practical use.)
>There may be other stuff to move over; Matthew or someone more familiar
>than I with the contrib version needs to take a look. (I have refrained
>from removing the contrib module until we're sure we have extracted
>everything from it.)
>
>

I will take a look for missing features, thanks for not removing it from
contrib yet.

As for the sleep factor I'm not sure it makes sense. It was initially
put in as a way to prevent autovacuum from running more than X% of the
time. However, I think the better answer these days is to use the vacuum
delay settings.

Speaking of which, I think I mentioned this to Alvaro, but I guess it
just didn't make it in. The pg_autovacuum table should have a few
additional columns that allow setting vacuum delay settings on a per
table basis. I also think that there should be GUC settings for the
default autovacuum delay settings which an admin might want to be
separate from the system wide default vacuum delay settings.

>* The code does not make a provision to ignore temporary tables.
>Although vacuum.c and analyze.c will disregard the request to touch
>such tables, it'd probably be better to recognize the situation further
>upstream. In particular it seems that autovacuum will continually throw
>ANALYZE requests for a temp table due to lack of stats.
>
>

Does the stats system track data about temp tables? If it doesn't then
autovacuum won't try to vacuum them. Will take a look.

>* ANALYZE also refuses to do anything with pg_statistic itself, which
>is another case that may need special treatment to avoid useless cycles.
>
>

Should be easy enough to tell autovacuum to ignore this table specifically.

>* For that matter I'm unconvinced that it's a good idea to try to force
>the pgstat DB to pick up every table in every database. If there's no
>entry it's because the table is not getting modified, and therefore it
>seems to me that we can just leave well enough alone. The code really
>is not very good about doing nothing where nothing is called for ;-)
>
>

I think in a production environment, this won't be an issue, but in a
development situation where the postmaster is getting stopped and
started fairly often, it could be an issue. Actually, if the stats
system doesn't reset it's data on postmaster restart, this shouldn't be
a problem. Any thoughts on changing this default?

>* The code ignores datallowconn and therefore will periodically vacuum
>template0. I've got mixed emotions about this --- it could save
>someone's bacon if they failed to properly VACUUM FREEZE a template
>database, but in 99.99% of installations it's just wasted cycles.
>Maybe it'd make sense to perform XID-wraparound-prevention vacuuming,
>but not anything more, in a template DB. Thoughts?
>
>

Sounds like a good idea. Bacon conservation is clearly one of the goals
of autovacuum.

>* Or actually, it would vacuum template0, except that since no regular
>backend ever connects to template0, there will be no stats DB entry for
>it and so the loop in AutoVacMain will ignore it. This is definitely
>BAD as it means that a database that's not been touched since postmaster
>start will never be vacuumed, not even for XID wraparound prevention.
>That test needs to be weakened.
>
>* I'm still pretty concerned about the handling of shared catalogs.
>AFAICS the current pgstats infrastructure simply gets this wrong,
>meaning that shared catalogs will not get adequate vacuuming. We need
>to fix that.
>
>

This was handled in the contrib version by only vacuuming shared
catalogs inside template1, however it would then analyze those tables in
each and every database. Is there a reason this solution is not
adequate? Or perhaps this concept doesn't translate to the integrated
version?

>* As Alvaro noted, the default parameter settings need a lookover.
>What is in the patch is not what was the default in the contrib module,
>but the contrib defaults seem awfully passive.
>
>

Alvaro and I talked about this. I suggested these as the new defaults
as there seemed to be a consensus that the defaults in the contrib
version were not very useful for most people. Hopefully these defaults
still a bit conservative, but useful.

>* The documentation badly needs work. I committed some minimal
>additions to runtime.sgml and catalogs.sgml, but the chapter about
>routine maintenance needs a section added about how to use autovac.
>

I promised Alvaro that I would do all the documentation. I will work on
it in the next few days now that the patch has been applied.

Thanks!

Matthew O'Connor


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 17:06:20
Message-ID: 20050714170620.GD19778@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, Jul 14, 2005 at 10:52:56AM -0400, Tom Lane wrote:
> I've applied Alvaro's latest integrated-autovacuum patch. There are
> still a number of loose ends to be dealt with before beta, though:

Thanks, and again sorry for the bugs. The code for shutting the whole
thing down was not easy for me to understand -- I think it should be
better documented. I can send a src/backend/postmaster/README file if
you think it's worth it; I'd document how to create processes, how to
handle shutdown, and how does the signalling mechanism work. (It took
me at least an hour to figure the signal handling out, and as you see I
still had gross misunderstadings.)

> * The code does not make a provision to ignore temporary tables.
> Although vacuum.c and analyze.c will disregard the request to touch
> such tables, it'd probably be better to recognize the situation further
> upstream. In particular it seems that autovacuum will continually throw
> ANALYZE requests for a temp table due to lack of stats.

Oh, is that right? Actually in the end I forgot about temp tables so I
didn't handle them specially, but now I remember that when I started
looking at Matthew's integration code I thought that temp tables should
be analyzed if they happen to have a lot of new tuples, so that the
planner would have good stats about them.

> * For that matter I'm unconvinced that it's a good idea to try to force
> the pgstat DB to pick up every table in every database. If there's no
> entry it's because the table is not getting modified, and therefore it
> seems to me that we can just leave well enough alone. The code really
> is not very good about doing nothing where nothing is called for ;-)

Hmm. The problem is that the table may merit a first ANALYZE, and in a
second run we need to know that another one is not needed. How would we
know that, if we don't keep track on it in the pgstat DB? Keeping no
info about a table seems problematic to me.

Also, remember that there were mentions of changing wraparound Xid to be
kept track of on a per-table basis, instead of per-database (for 8.2 I
assume). If this happens we will _need_ to check every table.

> * The code ignores datallowconn and therefore will periodically vacuum
> template0. I've got mixed emotions about this --- it could save
> someone's bacon if they failed to properly VACUUM FREEZE a template
> database, but in 99.99% of installations it's just wasted cycles.
> Maybe it'd make sense to perform XID-wraparound-prevention vacuuming,
> but not anything more, in a template DB. Thoughts?
>
> * Or actually, it would vacuum template0, except that since no regular
> backend ever connects to template0, there will be no stats DB entry for
> it and so the loop in AutoVacMain will ignore it. This is definitely
> BAD as it means that a database that's not been touched since postmaster
> start will never be vacuumed, not even for XID wraparound prevention.
> That test needs to be weakened.

See, that's what I'm talking about :-) No information about an object
is a problem. Now, I don't think it's a problem to periodically vacuum
template0, because it will connect to it and quickly realize that no
work is needed. OTOH I think you can argue that we document that
datallowcon=false databases should be frozen and thus we can just assume
that they don't need vacuuming. However this doesn't seem safe -- it'll
quickly end up in the "PostgreSQL gotchas" section.

Maybe we could pick the first database with no entry in pgstat, and
process that. After it's processed, pgstat will have complete data
about it.

Another idea would be keeping a per-database dead tuple counter, or some
other metric, and use that as a parameter in choosing what database to
vacuum. The current test (last autovac start time) is certainly very
naive.

Yet another idea is to keep track of current Xid as of the last autovac
start, and compare that with the current Xid, in order to check for
wraparound. Not sure if it's possible to check current Xid without
connecting to a database first.

> * I'm still pretty concerned about the handling of shared catalogs.
> AFAICS the current pgstats infrastructure simply gets this wrong,
> meaning that shared catalogs will not get adequate vacuuming. We need
> to fix that.

Maybe we can store them in pgstat in a pseudo-database with Oid=0, and
special case them everywhere. Where do we store pg_autovacuum values?
Or do we dictate that they can only use default parameters from GUC?

> * As Alvaro noted, the default parameter settings need a lookover.
> What is in the patch is not what was the default in the contrib module,
> but the contrib defaults seem awfully passive.

Yeah, the values you saw in the patch were suggested by Matthew. I had
the contrib module's values originally.

> * The documentation badly needs work. I committed some minimal
> additions to runtime.sgml and catalogs.sgml, but the chapter about
> routine maintenance needs a section added about how to use autovac.

Matthew is on that, I think.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Right now the sectors on the hard disk run clockwise, but I heard a rumor that
you can squeeze 0.2% more throughput by running them counterclockwise.
It's worth the effort. Recommended." (Gerry Pourwelle)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 18:04:58
Message-ID: 21177.1121364298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Oh, is that right? Actually in the end I forgot about temp tables so I
> didn't handle them specially, but now I remember that when I started
> looking at Matthew's integration code I thought that temp tables should
> be analyzed if they happen to have a lot of new tuples, so that the
> planner would have good stats about them.

You can't analyze temp tables of other sessions at all (and analyze.c
won't try) because you can't be certain of being able to access their
data. The valid data might only exist inside the local buffers of the
owning backend. Same goes for VACUUM --- basically, autovac has to keep
its fingers off temp tables altogether. (See nearby discussion with
Tom O'Connell for graphic evidence.)

>> * For that matter I'm unconvinced that it's a good idea to try to force
>> the pgstat DB to pick up every table in every database. If there's no
>> entry it's because the table is not getting modified, and therefore it
>> seems to me that we can just leave well enough alone. The code really
>> is not very good about doing nothing where nothing is called for ;-)

> Hmm. The problem is that the table may merit a first ANALYZE, and in a
> second run we need to know that another one is not needed. How would we
> know that, if we don't keep track on it in the pgstat DB?

If it's being touched at all, then it will get into the pgstat DB
because of the actions of regular backends. I am questioning the need
for autovac to force things into the pgstat DB when they are evidently
not being used otherwise.

(This argument becomes stronger if we don't reset the stats contents
at postmaster start, which is another open issue. I think we probably
do need to toss the old stats file after a WAL recovery, but maybe it
need not happen otherwise.)

> Also, remember that there were mentions of changing wraparound Xid to be
> kept track of on a per-table basis, instead of per-database (for 8.2 I
> assume). If this happens we will _need_ to check every table.

Exactly ... whether it is in pgstat or not. That does not translate to
a need to force pgstat entries to be made.

>> * Or actually, it would vacuum template0, except that since no regular
>> backend ever connects to template0, there will be no stats DB entry for
>> it and so the loop in AutoVacMain will ignore it. This is definitely
>> BAD as it means that a database that's not been touched since postmaster
>> start will never be vacuumed, not even for XID wraparound prevention.
>> That test needs to be weakened.

> See, that's what I'm talking about :-)

Yeah, but you're drawing the wrong conclusion. I'm saying that for a DB
or table that is not present in pgstat, it is reasonable to assume it is
not being used, and so our only responsibility is to prevent XID
wraparound on it --- which we can determine from the pg_database entry
(or pg_class entry if per-table wrap management happens). We do not need
to force a pgstat entry to be created, and we should not try.

> Another idea would be keeping a per-database dead tuple counter, or some
> other metric, and use that as a parameter in choosing what database to
> vacuum. The current test (last autovac start time) is certainly very
> naive.

Yeah, keeping per-database totals of the dead tuple counts would help,
and would cost little inside the stats collector AFAICS.

> Not sure if it's possible to check current Xid without
> connecting to a database first.

We could trivially expand the database flat file to include its
datfrozenxid, and any other fields we need from pg_database.

>> * I'm still pretty concerned about the handling of shared catalogs.

> Maybe we can store them in pgstat in a pseudo-database with Oid=0, and
> special case them everywhere.

Yeah, that's what I suggested before. I haven't thought of any holes in
the idea yet. The "special casing" shouldn't be hard --- you can just
use the same info set up for the Relation's rd_lockInfo.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 18:12:52
Message-ID: 21268.1121364772@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
> Speaking of which, I think I mentioned this to Alvaro, but I guess it
> just didn't make it in. The pg_autovacuum table should have a few
> additional columns that allow setting vacuum delay settings on a per
> table basis. I also think that there should be GUC settings for the
> default autovacuum delay settings which an admin might want to be
> separate from the system wide default vacuum delay settings.

I was thinking GUC settings only; is there a real use-case for
table-specific delay parameters? ISTM the point of the delay parameters
for autovac is to put a lid on its impact on interactive response. Seen
in that light, you do not care exactly which table it's hitting at the
moment.

>> * I'm still pretty concerned about the handling of shared catalogs.

> This was handled in the contrib version by only vacuuming shared
> catalogs inside template1, however it would then analyze those tables in
> each and every database. Is there a reason this solution is not
> adequate?

The problem is that now that we've invented the default postgres
database, it becomes more plausible to think about installations that
haven't got a template1 at all. I'd prefer a solution that does not
assume the presence of any specific database. ISTM reasonable to
process the shared catalogs symmetrically in every DB: look to see
if they need vacuuming or not. The problem (which was also a problem
for the contrib version) is that the stats system fails to maintain
a single set of stats for a shared catalog --- operations get counted
under whichever DB they were issued from. This means that autovac
will underestimate the need for vacuuming of a shared catalog, since
no matter where it looks from, it will see only a portion of the
true update activity.

regards, tom lane


From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 18:30:27
Message-ID: 42D6AF43.8080901@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:

>"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
>
>
>>Speaking of which, I think I mentioned this to Alvaro, but I guess it
>>just didn't make it in. The pg_autovacuum table should have a few
>>additional columns that allow setting vacuum delay settings on a per
>>table basis. I also think that there should be GUC settings for the
>>default autovacuum delay settings which an admin might want to be
>>separate from the system wide default vacuum delay settings.
>>
>>
>
>I was thinking GUC settings only; is there a real use-case for
>table-specific delay parameters? ISTM the point of the delay parameters
>for autovac is to put a lid on its impact on interactive response. Seen
>in that light, you do not care exactly which table it's hitting at the
>moment.
>
>

I was thinking of users that might not want the vacuum delay settings on
small tables that will normally be vacuumed very quickly. This isn't a
very strong argument, but I thought I should mention it. Also, given
the projects tenancy towards not giving knobs to users unless we are
sure they need them, I think GUC only would be OK.

>>This was handled in the contrib version by only vacuuming shared
>>catalogs inside template1, however it would then analyze those tables in
>>each and every database. Is there a reason this solution is not
>>adequate?
>>
>>
>
>The problem is that now that we've invented the default postgres
>database, it becomes more plausible to think about installations that
>haven't got a template1 at all. I'd prefer a solution that does not
>assume the presence of any specific database. ISTM reasonable to
>process the shared catalogs symmetrically in every DB: look to see
>if they need vacuuming or not. The problem (which was also a problem
>for the contrib version) is that the stats system fails to maintain
>a single set of stats for a shared catalog --- operations get counted
>under whichever DB they were issued from. This means that autovac
>will underestimate the need for vacuuming of a shared catalog, since
>no matter where it looks from, it will see only a portion of the
>true update activity.
>

Ok, so without reworking the stats system, I don't see an easy answer to
this other than autovacuum trying to sum up all the activity it finds in
all the different databases it looks at, but that seems rather ugly.
Any thoughts on improving the stats situation here?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 19:07:09
Message-ID: 27741.1121368029@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Thanks, and again sorry for the bugs. The code for shutting the whole
> thing down was not easy for me to understand -- I think it should be
> better documented. I can send a src/backend/postmaster/README file if
> you think it's worth it; I'd document how to create processes, how to
> handle shutdown, and how does the signalling mechanism work. (It took
> me at least an hour to figure the signal handling out, and as you see I
> still had gross misunderstadings.)

You can if you want, but I don't think that that will ever be
cookie-cutter stuff --- each specialized subjob we've added to date has
had slightly different requirements, and I'd expect the same if we add
more in future. You have to think about whether they need to connect to
shared memory, whether they can run transactions, which signals they
need to receive, what the postmaster's response should be to either a
normal or non-normal child exit, what the startup and shutdown order
should be, etc. All of these questions are interrelated ...

regards, tom lane


From: Hannu Krosing <hannu(at)skype(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 19:32:59
Message-ID: 1121369580.4897.14.camel@fuji.krosing.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On N, 2005-07-14 at 14:12 -0400, Tom Lane wrote:
> "Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
> > Speaking of which, I think I mentioned this to Alvaro, but I guess it
> > just didn't make it in. The pg_autovacuum table should have a few
> > additional columns that allow setting vacuum delay settings on a per
> > table basis. I also think that there should be GUC settings for the
> > default autovacuum delay settings which an admin might want to be
> > separate from the system wide default vacuum delay settings.
>
> I was thinking GUC settings only; is there a real use-case for
> table-specific delay parameters?

Probably not, unless we also have table-specific load and/or
maintenance-window thresholds above which they are not vacuumed.

Often there are some tables that need to be vacuumed constantly even at
the highest loads (usually small but fast-changing) and some that need
to be vacuumed only at lower activity periods (usually big and changing
at a lower rate).

> ISTM the point of the delay parameters
> for autovac is to put a lid on its impact on interactive response. Seen
> in that light, you do not care exactly which table it's hitting at the
> moment.

The only difference I can see is if vacuum is hitting the *same* table
as my critical functions or some *other* table.

If it's hitting the same one, there seems to be larger performance
impact, especially if I'm writing to that table.

This is just a gut feeling, not anything scientific :)

But I guess that current release of autovacuum can't handle parallel
vacuums anyway, so I just need to do the small/fast vacuums from my own
scripts.

This should be feasible if I can convince you of safety and usefullness
of my concurrent vacuum patch :)

--
Hannu Krosing <hannu(at)skype(dot)net>


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-14 19:41:55
Message-ID: 87pstlw4xo.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> I was thinking GUC settings only; is there a real use-case for
> table-specific delay parameters? ISTM the point of the delay parameters
> for autovac is to put a lid on its impact on interactive response. Seen
> in that light, you do not care exactly which table it's hitting at the
> moment.

I'm not sure that's true.

ISTM if you have a small table that needs to be vacuumed frequently you
probably don't want it taking longer than necessary to vacuum. It's probably
mostly cached so there wouldn't be much of an i/o hit and even a small sleep
can make a big proportional difference in vacuum run time. You could get into
a situation where it takes longer to vacuum a bunch of such tables than the
frequency you need the vacuuming to taking place.

I think the i/o problem comes when you have large uncached tables. They
probably have a relatively small percentage of the table being updated and so
don't need to be vacuumed frequently. But when they do you need the sleeps to
avoid the i/o problems.

--
greg


From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Autovacuum loose ends
Date: 2005-07-16 22:32:28
Message-ID: 42D98AFC.6050808@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
>
> ISTM the point of the delay parameters
> for autovac is to put a lid on its impact on interactive response. Seen
> in that light, you do not care exactly which table it's hitting at the
> moment.

Unless the table in question takes a big lock when it's VACUUMed
like tables with GiST indexes do today.

Slowing down one of those vacuums on a larger table has a huge
impact on interactive responses.

With GiST indexes becoming concurrent I assume Vacuum won't lock
anymore on my tables; but I don't know if there are other index
types or condition that might make vacuums take out similar
table-wide locks.

Ron


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-17 04:43:15
Message-ID: 25124.1121575395@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> writes:
> Tom Lane wrote:
>> ISTM the point of the delay parameters
>> for autovac is to put a lid on its impact on interactive response. Seen
>> in that light, you do not care exactly which table it's hitting at the
>> moment.

> Unless the table in question takes a big lock when it's VACUUMed
> like tables with GiST indexes do today.

Well, the issue there is not at the table level, but only while the
individual index is being cleaned.

I suggested a few days ago that we ought not do vacuum delays at all
while processing an index that needs an exclusive lock (this no longer
includes gist, but rtree and to a lesser extent hash still have issues).

If you don't like that, I think you'd pretty much have to invent autovac
delays that are tunable on a *per index* basis, not per table. That
seems a bit over the top to me; it'd be a nontrivial amount of work to
implement, and there's no evidence that it's better than just removing
the vacuum_delay_point calls in rtree and hash.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-22 22:54:32
Message-ID: 20050722225432.GA2734@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, Jul 14, 2005 at 10:52:56AM -0400, Tom Lane wrote:

Hey,

> * Or actually, it would vacuum template0, except that since no regular
> backend ever connects to template0, there will be no stats DB entry for
> it and so the loop in AutoVacMain will ignore it. This is definitely
> BAD as it means that a database that's not been touched since postmaster
> start will never be vacuumed, not even for XID wraparound prevention.
> That test needs to be weakened.

I've hacked the whole thing enough that I fixed most of the issues.
However this one I don't know how to handle. What I need to do is
compare each database's frozen Xid with the current transaction Id.
I can get the frozenxid from the flatfile -- however I don't have
anything with which to compare it. I tried ReadNewTransactionId(), but
it doesn't work because it tries to acquire a LWLock, which isn't
possible because we don't have a PGPROC before connecting to a database.

I guess I could the Xid from pg_control. This seems unclean however.
Opinions about doing that? Better ideas?

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Crear es tan difícil como ser libre" (Elsa Triolet)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-22 23:37:53
Message-ID: 17412.1122075473@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> I've hacked the whole thing enough that I fixed most of the issues.
> However this one I don't know how to handle. What I need to do is
> compare each database's frozen Xid with the current transaction Id.
> I can get the frozenxid from the flatfile -- however I don't have
> anything with which to compare it. I tried ReadNewTransactionId(), but
> it doesn't work because it tries to acquire a LWLock, which isn't
> possible because we don't have a PGPROC before connecting to a database.

> I guess I could the Xid from pg_control. This seems unclean however.
> Opinions about doing that? Better ideas?

Getting it from pg_control isn't that bad; the value could be as old as
the last checkpoint, but that should be close enough for this purpose.

The only alternative I can see is for the stats daemon to try to track
recent values of nextXID and include the latest in the stats datafile.
You really wouldn't want to put XID into every stats message, but you
could put it into PgStat_MsgAutovacStart say, so that each autovac run
would seed the XID information for the next run. On the whole it's not
clear this is cleaner than looking to pg_control.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Autovacuum loose ends
Date: 2005-07-23 01:16:05
Message-ID: 20050723011605.GC2734@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Jul 22, 2005 at 07:37:53PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > I've hacked the whole thing enough that I fixed most of the issues.
> > However this one I don't know how to handle. What I need to do is
> > compare each database's frozen Xid with the current transaction Id.
> > I can get the frozenxid from the flatfile -- however I don't have
> > anything with which to compare it. I tried ReadNewTransactionId(), but
> > it doesn't work because it tries to acquire a LWLock, which isn't
> > possible because we don't have a PGPROC before connecting to a database.
>
> > I guess I could the Xid from pg_control. This seems unclean however.
> > Opinions about doing that? Better ideas?
>
> Getting it from pg_control isn't that bad; the value could be as old as
> the last checkpoint, but that should be close enough for this purpose.

Ok, fair enough.

That makes me wonder however if the test should be heavier. Right now,
the test is

/*
* We decide to vacuum at the same point where vacuum.c's
* vac_truncate_clog() would decide start giving warnings.
*/
age = (int32) (ReadNewTransactionId() - db->frozenxid);
whole_db = (age > (int32) ((MaxTransactionId >> 3) * 3));

Now that we are going to test a TransactionId that was current slightly
in the past, maybe it should instead read

whole_db = (age > (int32) ((MaxTransactionId >> 3) * 4));

so that vac_truncate_clog doesn't start emitting warning just before we
do the vacuum.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
FOO MANE PADME HUM


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-24 18:21:25
Message-ID: 20050724182125.GA22411@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, Jul 14, 2005 at 10:52:56AM -0400, Tom Lane wrote:
> I've applied Alvaro's latest integrated-autovacuum patch. There are
> still a number of loose ends to be dealt with before beta, though:

Ok, here's a patch that deals with some of this:

- The stat collector is modified so as to keep shared relations separate
from regular ones. Also, backends sends messages separately.
Autovacuum takes advantage of this, so it correctly identifies the
appropiate time to operate on a shared relation, irrespective of the
database where they were modified. Note however that it uses each
database's pg_autovacuum settings. This means it could be vacuumed
sooner in one database than another, but I don't think it's a problem.

- Temp tables are completely ignored.

- pg_statistic is completely ignored.

- databases with no stat entry are still ignored, except that they are
checked for Xid wraparound like any other. The "oldest" one is chosen
for vacuum in a particular autovacuum run.

- A database-wide vacuum forces a pg_database flat-file update, so that
the wraparound check actually works.

- The postmaster's main loop sleeps Min(60, autovacuum_naptime), in
order to be able to pick naptimes smaller than 60 seconds. In order
not to make the loop a busy-wait, I forced a minimum of 1 to that GUC
var.

Some comments:

- Now that we have a real Xid wraparound check, we could go back to
having any table with no stat entry ignored, which was the original
coding. There's no danger of wraparound, and there'd be no work done
to a table that doesn't have any activity. We have to consider what
happens at stat reset -- AFAICS there's no problem, because as soon as
the table sees some activity, it will be picked up by pgstat.
However, it would be bad if stats are reset right after some heavy
activity on a table. Maybe the only thing we need is documentation.

- datallowcon is still ignored. Now it's safe to do so, because we have
a real Xid wraparound check. Changing it requires extending the
pg_database flat-file (should be fairly easy).

- There are stat messages emitted for a database-wide vacuum, just like
any other. This means that all tables in the database would end up in
pgstat; and also all databases, including those with datallowconn = false.
This may not be good. I'm not sure what exactly to do about it. Do
we want to disallow such stats? Disable message sending (or
collecting) in some circumstances?

- I haven't done anything yet w.r.t. the custom vacuum_delay nor sleep
scale factor.

- There are still no docs.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Porque Kim no hacia nada, pero, eso sí,
con extraordinario éxito" ("Kim", Kipling)

Attachment Content-Type Size
autovac-two-1.patch text/plain 41.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-24 18:33:38
Message-ID: 21936.1122230018@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> - pg_statistic is completely ignored.

... pg_statistic still needs vacuuming, surely. It's only ANALYZE
that you can/should skip for it.

> - The postmaster's main loop sleeps Min(60, autovacuum_naptime), in
> order to be able to pick naptimes smaller than 60 seconds. In order
> not to make the loop a busy-wait, I forced a minimum of 1 to that GUC
> var.

Hmm, I wonder whether the minimum shouldn't be 10. Or even 60.

> - Now that we have a real Xid wraparound check, we could go back to
> having any table with no stat entry ignored, which was the original
> coding. There's no danger of wraparound, and there'd be no work done
> to a table that doesn't have any activity.

Agreed.

> We have to consider what
> happens at stat reset -- AFAICS there's no problem, because as soon as
> the table sees some activity, it will be picked up by pgstat.
> However, it would be bad if stats are reset right after some heavy
> activity on a table. Maybe the only thing we need is documentation.

What's the use-case for having the stat reset feature at all?

> - datallowcon is still ignored. Now it's safe to do so, because we have
> a real Xid wraparound check. Changing it requires extending the
> pg_database flat-file (should be fairly easy).

I think this is all right, as long as a database that shows no stats
traffic is only connected to when it needs to be vacuumed for XID wrap
prevention purposes.

> - There are stat messages emitted for a database-wide vacuum, just like
> any other. This means that all tables in the database would end up in
> pgstat; and also all databases, including those with datallowconn = false.
> This may not be good. I'm not sure what exactly to do about it. Do
> we want to disallow such stats? Disable message sending (or
> collecting) in some circumstances?

Needs thought...

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-24 20:06:51
Message-ID: 20050724200651.GA23014@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Sun, Jul 24, 2005 at 02:33:38PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > - pg_statistic is completely ignored.
>
> ... pg_statistic still needs vacuuming, surely. It's only ANALYZE
> that you can/should skip for it.

Sorry, yes, it's ignored only for analyze.

> > - The postmaster's main loop sleeps Min(60, autovacuum_naptime), in
> > order to be able to pick naptimes smaller than 60 seconds. In order
> > not to make the loop a busy-wait, I forced a minimum of 1 to that GUC
> > var.
>
> Hmm, I wonder whether the minimum shouldn't be 10. Or even 60.

It's ok with me. What do other people think?

> > We have to consider what
> > happens at stat reset -- AFAICS there's no problem, because as soon as
> > the table sees some activity, it will be picked up by pgstat.
> > However, it would be bad if stats are reset right after some heavy
> > activity on a table. Maybe the only thing we need is documentation.
>
> What's the use-case for having the stat reset feature at all?

I don't know. Maybe the people who added it can tell?

> > - There are stat messages emitted for a database-wide vacuum, just like
> > any other. This means that all tables in the database would end up in
> > pgstat; and also all databases, including those with datallowconn = false.
> > This may not be good. I'm not sure what exactly to do about it. Do
> > we want to disallow such stats? Disable message sending (or
> > collecting) in some circumstances?
>
> Needs thought...

Ok.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"I call it GNU/Linux. Except the GNU/ is silent." (Ben Reiter)


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-25 01:31:15
Message-ID: 42E440E3.8040106@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

>> We have to consider what
>> happens at stat reset -- AFAICS there's no problem, because as soon as
>> the table sees some activity, it will be picked up by pgstat.
>> However, it would be bad if stats are reset right after some heavy
>> activity on a table. Maybe the only thing we need is documentation.
>
>
> What's the use-case for having the stat reset feature at all?

I believe I was the root cause of the pg_stat_reset() function. The
idea at the time was that if you decide to do a round of index
optimisation, you want to be able to search for unused indexes and
heavily seq. scanned tables.

If you reset the stats you have 'clean' data to work with. For
instance, you can get 24 hours of clean stats data.

Chris


From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-25 04:45:26
Message-ID: 42E46E66.70402@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera wrote:

>On Sun, Jul 24, 2005 at 02:33:38PM -0400, Tom Lane wrote:
>
>
>>Hmm, I wonder whether the minimum shouldn't be 10. Or even 60.
>>
>>
>
>It's ok with me. What do other people think?
>
>

Effectiely, this is going to be the minimum amount of "down time" for
autovacuum between checking databases, right? So if the minimum is 10
seconds, and there I have six databases, then it will check each
database at most once per minute? If so, then I'm not sure what I think
if I have a few hundred databases, 10s might be too long.

>>What's the use-case for having the stat reset feature at all?
>>
>>
>
>I don't know. Maybe the people who added it can tell?
>
>

I don't know either, but this brings up another question. Stats
wraparound. The n_tup_ins/upd/del columns in the stats system are
defined as bigint, what happens when the total number of upd for example
exceeds the capacity for bigint, or overflows to negative, anyone have
any idea?

Matt


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-25 04:59:01
Message-ID: 19938.1122267541@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
> I don't know either, but this brings up another question. Stats
> wraparound. The n_tup_ins/upd/del columns in the stats system are
> defined as bigint, what happens when the total number of upd for example
> exceeds the capacity for bigint, or overflows to negative, anyone have
> any idea?

We'll all be safely dead, for one thing ;-)

At one update per nanosecond, it'd take approximately 300 years to wrap
a 64-bit counter. Somehow I don't have a problem with the idea that
Postgres would need to be rebooted that often. We'd want to fix the
32-bit nature of XIDs long before 64-bit stats counters get to be a
real-world issue ...

regards, tom lane


From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-25 15:33:37
Message-ID: 42E50651.3040603@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:

>"Matthew T. O'Connor" <matthew(at)zeut(dot)net> writes:
>
>
>>I don't know either, but this brings up another question. Stats
>>wraparound.
>>
>We'll all be safely dead, for one thing ;-)
>
>At one update per nanosecond, it'd take approximately 300 years to wrap
>a 64-bit counter. Somehow I don't have a problem with the idea that
>Postgres would need to be rebooted that often. We'd want to fix the
>32-bit nature of XIDs long before 64-bit stats counters get to be a
>real-world issue ...
>

*sigh* Sorry, I should have done a little math before I asked that
question.....


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-26 04:59:14
Message-ID: 20050726045914.GA5279@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, Jul 14, 2005 at 10:52:56AM -0400, Tom Lane wrote:
> I've applied Alvaro's latest integrated-autovacuum patch. There are
> still a number of loose ends to be dealt with before beta, though:

Updated this patch:

- The stat collector is modified so as to keep shared relations separate
from regular ones. Autovacuum understands this.

- Temp tables are completely ignored.

- pg_statistic is ignored for analyze. It's still candidate for vacuum.

- databases with no stat entry are still ignored, except that they are
checked for Xid wraparound like any other. The "oldest" one is chosen
for vacuum in a particular autovacuum run.

- A database-wide vacuum forces a pg_database flat-file update, so that
the wraparound check actually works.

- The postmaster's main loop sleeps Min(60, autovacuum_naptime), in
order to be able to pick naptimes smaller than 60 seconds. In order
not to make the loop a busy-wait, I forced a minimum of 1 to that GUC
var. Yes, an argument could be made that the minimum could be higher.
Not sure if we actually want to dictate policy on this. The minimum
is there only to prevent the postmaster from using 100% of a CPU the
whole time.

- Tables with no stat entries are completely ignored.

- The stat collector ignores messages that relate to databases it
doesn't know about. This makes it inocuous to issue a database-wide
vacuum on a template database. A special case is made for database
InvalidOid -- an entry for it is created regardless.

Two comments still apply:

- I haven't done anything yet w.r.t. the custom vacuum_delay nor sleep
scale factor.

- There are still no docs.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Porque Kim no hacia nada, pero, eso sí,
con extraordinario éxito" ("Kim", Kipling)

Attachment Content-Type Size
autovac-two-2.patch text/plain 47.3 KB

From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-26 15:45:19
Message-ID: 42E65A8F.70705@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera wrote:

>Two comments still apply:
>
>- I haven't done anything yet w.r.t. the custom vacuum_delay nor sleep
> scale factor.
>

I don't think we need the sleep scaling factor. Before we had vacuum
delay settings, it might have been useful as a means of throttling down
the impact of autovacuum, but I think the delay settings are the better
way to go.

As for the custom vacuum_delay settings, Tom Lane's commented that it
probably wasn't needed. However I and several others responded saying
that it probably would be useful for certain use cases. I'm still not
sure how compelling that case is but it seems like a simple addition.
Perhaps this is something we can add for 8.2 if people seem to want it.

>- There are still no docs.
>

I'm on the hook for this and will start working on them next week.


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-27 20:26:14
Message-ID: 20050727202614.GE1832@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Mon, Jul 25, 2005 at 09:31:15AM +0800, Christopher Kings-Lynne wrote:
> >> We have to consider what
> >> happens at stat reset -- AFAICS there's no problem, because as soon as
> >> the table sees some activity, it will be picked up by pgstat.
> >> However, it would be bad if stats are reset right after some heavy
> >> activity on a table. Maybe the only thing we need is documentation.
> >
> >What's the use-case for having the stat reset feature at all?
>
> I believe I was the root cause of the pg_stat_reset() function. The
> idea at the time was that if you decide to do a round of index
> optimisation, you want to be able to search for unused indexes and
> heavily seq. scanned tables.
>
> If you reset the stats you have 'clean' data to work with. For
> instance, you can get 24 hours of clean stats data.

Ok, so there's a reason for having a manual stat-reset. However what's
the rationale for cleaning stats at postmaster start? In fact I think
it's actively bad because you lose any data you had before postmaster
stop/crash.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"I personally became interested in Linux while I was dating an English major
who wouldn't know an operating system if it walked up and bit him."
(Val Henson)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-27 22:05:00
Message-ID: 11698.1122501900@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Ok, so there's a reason for having a manual stat-reset. However what's
> the rationale for cleaning stats at postmaster start? In fact I think
> it's actively bad because you lose any data you had before postmaster
> stop/crash.

We probably *should* drop the stats file if any WAL replay activity
occurs, because the stats file could be out of sync with reality
--- this is particularly important in a PITR recovery situation,
where the stats file is likely to be WAY out of sync. (Maybe only
clobber it in PITR mode?)

I agree that the argument for doing it in a normal restart is pretty
weak.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-29 15:19:34
Message-ID: 18027.1122650374@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

BTW, is there still any reason not to remove the contrib/pg_autovacuum
directory from CVS?

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-29 15:41:48
Message-ID: 20050729154148.GE15480@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Jul 29, 2005 at 11:19:34AM -0400, Tom Lane wrote:
> BTW, is there still any reason not to remove the contrib/pg_autovacuum
> directory from CVS?

I still haven't added custom cost-based delays, but I don't see that as
a showstopper for removing it. I just went through the CVS log and I
don't see anything else that applies.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
Voy a acabar con todos los humanos / con los humanos yo acabaré
voy a acabar con todos / con todos los humanos acabaré (Bender)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-29 19:33:09
Message-ID: 18143.1122665589@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Updated this patch:
> - The stat collector is modified so as to keep shared relations separate
> from regular ones. Autovacuum understands this.
> [etc]

Applied with some fixes --- you had broken the reporting of statistics
for shared tables, for one thing. Also the patch seemed to be missing
diffs for header files?

It occurs to me that vacuuming to prevent XID wraparound is not the only
reason to do DB-wide vacuums: we also need to keep
pg_database.datvacuumxid from getting too old, else we will have
problems with clog bloat. We may need to rethink the test used.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-29 19:48:05
Message-ID: 20050729194805.GC16537@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Jul 29, 2005 at 03:33:09PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > Updated this patch:
> > - The stat collector is modified so as to keep shared relations separate
> > from regular ones. Autovacuum understands this.
> > [etc]
>
> Applied with some fixes --- you had broken the reporting of statistics
> for shared tables, for one thing.

Oops :-( Didn't notice that.

> Also the patch seemed to be missing diffs for header files?

Damn, I generated the diff from within src/backend instead of the root
:-( Sorry for the inconvenience.

> It occurs to me that vacuuming to prevent XID wraparound is not the only
> reason to do DB-wide vacuums: we also need to keep
> pg_database.datvacuumxid from getting too old, else we will have
> problems with clog bloat. We may need to rethink the test used.

Hmm. Will see about it.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"La Primavera ha venido. Nadie sabe como ha sido" (A. Machado)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-29 21:46:11
Message-ID: 21890.1122673571@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
>> Also the patch seemed to be missing diffs for header files?

> Damn, I generated the diff from within src/backend instead of the root
> :-( Sorry for the inconvenience.

No problem --- reverse-engineering the changes to function declarations
was simple enough. But did you have any other changes outside
src/backend?

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-29 22:06:18
Message-ID: 20050729220618.GG16537@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Jul 29, 2005 at 05:46:11PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> >> Also the patch seemed to be missing diffs for header files?
>
> > Damn, I generated the diff from within src/backend instead of the root
> > :-( Sorry for the inconvenience.
>
> No problem --- reverse-engineering the changes to function declarations
> was simple enough. But did you have any other changes outside
> src/backend?

Nope, that was it.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Estoy de acuerdo contigo en que la verdad absoluta no existe...
El problema es que la mentira sí existe y tu estás mintiendo" (G. Lama)


From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-30 13:42:15
Message-ID: 02b901c5950c$7f85d2b0$8802460a@zaphod
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera wrote:

> I still haven't added custom cost-based delays, but I don't see that as
> a showstopper for removing it. I just went through the CVS log and I
> don't see anything else that applies.

I think you should at least add an autovacuum specific value for
"vacuum_cost_delay" because it turns cost-based vacuum delay on or off. I
believe not many will have vacuum_cost_delay enabled in postgresql.conf, but
will want to enable it for autovacuum.
At least I do.

Best Regards,
Michael Paesold


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Michael Paesold" <mpaesold(at)gmx(dot)at>
Cc: "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-30 14:37:57
Message-ID: 26613.1122734277@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

"Michael Paesold" <mpaesold(at)gmx(dot)at> writes:
> Alvaro Herrera wrote:
>> I still haven't added custom cost-based delays, but I don't see that as
>> a showstopper for removing it. I just went through the CVS log and I
>> don't see anything else that applies.

> I think you should at least add an autovacuum specific value for
> "vacuum_cost_delay" because it turns cost-based vacuum delay on or off.

It occurs to me that you could have that today, using the knowledge that
the autovac daemon runs as the bootstrap user: use ALTER USER SET to
attach user-specific vacuum delay settings to that role. This is a
pretty bletcherous solution, because (a) it requires knowledge of an
undocumented implementation detail and (b) it would interfere with using
that role for normal manual maintenance. So I agree that a few extra
GUC settings would be better. But we could get away without 'em.

Along the same lines, it was suggested that we need a way to disable
stats gathering on a per-database basis. We already have it: you can
use ALTER DATABASE SET to control stats_row_level and stats_block_level
that way. Neither of the above two objections apply to this usage, so
I think we can mark off that wishlist item as "done". (Of course, the
soon-to-appear autovac documentation had better mention this trick.)

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Paesold <mpaesold(at)gmx(dot)at>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-30 14:42:41
Message-ID: 200507301442.j6UEgfR13357@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> "Michael Paesold" <mpaesold(at)gmx(dot)at> writes:
> > Alvaro Herrera wrote:
> >> I still haven't added custom cost-based delays, but I don't see that as
> >> a showstopper for removing it. I just went through the CVS log and I
> >> don't see anything else that applies.
>
> > I think you should at least add an autovacuum specific value for
> > "vacuum_cost_delay" because it turns cost-based vacuum delay on or off.
>
> It occurs to me that you could have that today, using the knowledge that
> the autovac daemon runs as the bootstrap user: use ALTER USER SET to
> attach user-specific vacuum delay settings to that role. This is a
> pretty bletcherous solution, because (a) it requires knowledge of an
> undocumented implementation detail and (b) it would interfere with using
> that role for normal manual maintenance. So I agree that a few extra
> GUC settings would be better. But we could get away without 'em.
>
> Along the same lines, it was suggested that we need a way to disable
> stats gathering on a per-database basis. We already have it: you can
> use ALTER DATABASE SET to control stats_row_level and stats_block_level
> that way. Neither of the above two objections apply to this usage, so
> I think we can mark off that wishlist item as "done". (Of course, the
> soon-to-appear autovac documentation had better mention this trick.)

I am thinking we should move ahead with what we have now, suggest the
work-arounds, and thensee what use-cases we have for it for later
releases.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Michael Paesold <mpaesold(at)gmx(dot)at>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-30 14:55:33
Message-ID: 26777.1122735333@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>>> I think you should at least add an autovacuum specific value for
>>> "vacuum_cost_delay" because it turns cost-based vacuum delay on or off.

> I am thinking we should move ahead with what we have now, suggest the
> work-arounds, and thensee what use-cases we have for it for later
> releases.

I think it's absolutely unquestionable that there is a use-case for
running autovac with different vacuum-delay settings than you would
want to apply to manually issued vacuums. We don't need to wait for
field experience on that one; we already have it with the contrib
version.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Paesold <mpaesold(at)gmx(dot)at>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-30 14:57:15
Message-ID: 200507301457.j6UEvFR20670@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >>> I think you should at least add an autovacuum specific value for
> >>> "vacuum_cost_delay" because it turns cost-based vacuum delay on or off.
>
> > I am thinking we should move ahead with what we have now, suggest the
> > work-arounds, and thensee what use-cases we have for it for later
> > releases.
>
> I think it's absolutely unquestionable that there is a use-case for
> running autovac with different vacuum-delay settings than you would
> want to apply to manually issued vacuums. We don't need to wait for
> field experience on that one; we already have it with the contrib
> version.

So do we need to add new GUC variables?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paesold <mpaesold(at)gmx(dot)at>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-30 16:51:56
Message-ID: 20050730165156.GC24844@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Sat, Jul 30, 2005 at 10:57:15AM -0400, Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > >>> I think you should at least add an autovacuum specific value for
> > >>> "vacuum_cost_delay" because it turns cost-based vacuum delay on or off.
> >
> > > I am thinking we should move ahead with what we have now, suggest the
> > > work-arounds, and thensee what use-cases we have for it for later
> > > releases.
> >
> > I think it's absolutely unquestionable that there is a use-case for
> > running autovac with different vacuum-delay settings than you would
> > want to apply to manually issued vacuums. We don't need to wait for
> > field experience on that one; we already have it with the contrib
> > version.
>
> So do we need to add new GUC variables?

I was thinking in a GUC var for global setting, and a column in
pg_autovacuum for individual, per table setting. Just one, for the
vacuum_cost_limit parameter; I don't think we really need settable cost
parameters.

A case could be made for setting the vacuum_cost_delay parameter as
well. Thoughts?

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Es filósofo el que disfruta con los enigmas" (G. Coli)


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-31 17:02:33
Message-ID: 20050731170233.GA3595@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Jul 29, 2005 at 03:33:09PM -0400, Tom Lane wrote:

> It occurs to me that vacuuming to prevent XID wraparound is not the only
> reason to do DB-wide vacuums: we also need to keep
> pg_database.datvacuumxid from getting too old, else we will have
> problems with clog bloat. We may need to rethink the test used.

I was unable to come up with a reasonable test for this. How would we
determine what is "too old"? Of course, I could pick any number from
thin air, if that was what you were thinking. Going forward (8.2) I
think this should also be handled on a table per table basis, just like
the freeze Xid limit.

OTOH I just saw this comment in createdb():

/*
* Normally we mark the new database with the same datvacuumxid and
* datfrozenxid as the source. However, if the source is not allowing
* connections then we assume it is fully frozen, and we can set the
* current transaction ID as the xid limits. This avoids immediately
* starting to generate warnings after cloning template0.
*/

This means that if the user manages to unfreeze a database, disallow
connections, and later use it as a template, we could suffer Xid-
wraparound data loss in the new database. Should we rethink this?
Sadly, the only interface for disallowing connections is to manually
update pg_database, so it's impossible to raise a warning about it, or
something; and it's quite likely that people will disallow connections
without reading the proper documentation. (They do such things all the
time).

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"La experiencia nos dice que el hombre peló millones de veces las patatas,
pero era forzoso admitir la posibilidad de que en un caso entre millones,
las patatas pelarían al hombre" (Ijon Tichy)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-31 19:15:35
Message-ID: 593.1122837335@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> On Fri, Jul 29, 2005 at 03:33:09PM -0400, Tom Lane wrote:
>> It occurs to me that vacuuming to prevent XID wraparound is not the only
>> reason to do DB-wide vacuums: we also need to keep
>> pg_database.datvacuumxid from getting too old, else we will have
>> problems with clog bloat. We may need to rethink the test used.

> I was unable to come up with a reasonable test for this. How would we
> determine what is "too old"?

Well, it depends what you think is too much space for pg_clog. If we
just follow the standard anti-wrap policy, we'll vacuum at least once
every half billion transactions, so pg_clog could be expected to grow
to about 125Mb, which maybe isn't a problem these days.

> OTOH I just saw this comment in createdb():

> /*
> * Normally we mark the new database with the same datvacuumxid and
> * datfrozenxid as the source. However, if the source is not allowing
> * connections then we assume it is fully frozen, and we can set the
> * current transaction ID as the xid limits. This avoids immediately
> * starting to generate warnings after cloning template0.
> */

> This means that if the user manages to unfreeze a database, disallow
> connections, and later use it as a template, we could suffer Xid-
> wraparound data loss in the new database. Should we rethink this?

I don't think so. Fooling with a template database is risky in any
case, and the fact that autovacuum might save your bacon (if you are
running autovacuum) doesn't make it less so.

BTW, it strikes me that there is one serious error in the current
autovac logic: it does VACUUM ANALYZE rather than merely VACUUM
when doing XID-wrap protection. This means that it actively introduces
unfrozen tuples into template databases, which is A Bad Move. We
should just VACUUM, instead.

> Sadly, the only interface for disallowing connections is to manually
> update pg_database,

As of now, we have a documented way of disallowing connections that
doesn't involve messing with datallowconn, so this argument seems a
lot weaker than it might have awhile back.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-07-31 23:36:36
Message-ID: 20050731233636.GA18237@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Here is another patch for autovacuum:

- vacuum_cost_delay and vacuum_cost_limit can be set per table, as well
as globally with autovacuum_vacuum_cost_{limit,delay}

- pgstat is reset if recovery is required

- pgstat reset at postmaster start is disabled by default

- Xid-wraparound VACUUM is now FULL without ANALYZE

Note that because of the cost parameters, I changed the vacuum call in a
per-table call instead of passing a list of Oids. This could be changed
by having two separate lists, one which uses the default values and
other for the rest, but it hardly seems worth the trouble.

(This patch requires catversion bump.)

On Sun, Jul 31, 2005 at 03:15:35PM -0400, Tom Lane wrote:

> BTW, it strikes me that there is one serious error in the current
> autovac logic: it does VACUUM ANALYZE rather than merely VACUUM
> when doing XID-wrap protection. This means that it actively introduces
> unfrozen tuples into template databases, which is A Bad Move. We
> should just VACUUM, instead.

True. Changed in the attached patch.

I think this completes our expectations for 8.1, doesn't it? Now we
only need the documentation.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"I call it GNU/Linux. Except the GNU/ is silent." (Ben Reiter)

Attachment Content-Type Size
autovac-three-1.patch text/plain 19.4 KB

From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-01 07:55:11
Message-ID: 0bea01c5966e$58cd5db0$d501a8c0@zaphod
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera wrote:

> Here is another patch for autovacuum:
...
> - Xid-wraparound VACUUM is now FULL without ANALYZE

Am I right in my assumption that this VACUUM FULL can happen for any
database, not just a template database?

I think this is a bad idea. Vacuum full is not an option for our and many
other production databases. I suggest that should be a plain VACUUM.

Otherwise I think you have done great job finally integrating auto vacuum
into the backend.

Best Regards,
Michael Paesold


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Michael Paesold <mpaesold(at)gmx(dot)at>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-01 13:14:24
Message-ID: 20050801131424.GA23473@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Mon, Aug 01, 2005 at 09:55:11AM +0200, Michael Paesold wrote:
> Alvaro Herrera wrote:
>
> >Here is another patch for autovacuum:
> ...
> >- Xid-wraparound VACUUM is now FULL without ANALYZE
>
> Am I right in my assumption that this VACUUM FULL can happen for any
> database, not just a template database?

Ah, right. I think it would be OK if we made it FULL only for
datallowcon=false databases. OTOH maybe it's not worth at all making
the distinction and we should continue using the previous policy of
issuing only non-FULL VACUUM.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Having your biases confirmed independently is how scientific progress is
made, and hence made our great society what it is today" (Mary Gardiner)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Michael Paesold <mpaesold(at)gmx(dot)at>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-01 14:03:59
Message-ID: 2444.1122905039@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
>>> - Xid-wraparound VACUUM is now FULL without ANALYZE
>>
>> Am I right in my assumption that this VACUUM FULL can happen for any
>> database, not just a template database?

> Ah, right. I think it would be OK if we made it FULL only for
> datallowcon=false databases. OTOH maybe it's not worth at all making
> the distinction and we should continue using the previous policy of
> issuing only non-FULL VACUUM.

Strikes me as a waste of cycles: the one database *least* likely to be
in need of a VACUUM FULL is template0.

What we perhaps should consider is VACUUM FREEZE, not FULL, when hitting
a template database --- this would maximize the interval before needing
to do it again.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-08 17:38:58
Message-ID: 20050808173858.GA12487@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Sun, Jul 31, 2005 at 07:36:36PM -0400, Alvaro Herrera wrote:

Updated this patch:

> - vacuum_cost_delay and vacuum_cost_limit can be set per table, as well
> as globally with autovacuum_vacuum_cost_{limit,delay}
>
> - pgstat is reset if recovery is required
>
> - pgstat reset at postmaster start is disabled by default

- Xid-wraparound VACUUM is now FREEZE without ANALYZE, iff the database
has datallowconn=false or datistemplate=true

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"No hay cielo posible sin hundir nuestras raíces
en la profundidad de la tierra" (Malucha Pinto)

Attachment Content-Type Size
autovac-three-2.patch text/plain 29.4 KB

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-10 03:05:43
Message-ID: 20050810030543.GA2675@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Jul 29, 2005 at 03:33:09PM -0400, Tom Lane wrote:

> It occurs to me that vacuuming to prevent XID wraparound is not the only
> reason to do DB-wide vacuums: we also need to keep
> pg_database.datvacuumxid from getting too old, else we will have
> problems with clog bloat. We may need to rethink the test used.

Hmm. I have a patch for this, but now that it's ready, I wonder if it's
really needed. If I understand vacuum_set_xid_limits() correctly, it's
very difficult for the vacuumxid to be far behind the freeze limit. And
in the case it's actually behind, then there's nothing we can do -- the
only way out is for the user to end the long-running transaction.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Cómo ponemos nuestros dedos en la arcilla del otro. Eso es la amistad; jugar
al alfarero y ver qué formas se pueden sacar del otro" (C. Halloway en
La Feria de las Tinieblas, R. Bradbury)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-10 03:24:40
Message-ID: 21937.1123644280@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Hmm. I have a patch for this, but now that it's ready, I wonder if it's
> really needed. If I understand vacuum_set_xid_limits() correctly, it's
> very difficult for the vacuumxid to be far behind the freeze limit.

Umm ... they can be close together, or a billion XIDs apart, depending
on whether the FREEZE option was used.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-10 03:58:02
Message-ID: 20050810035802.GA3044@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Tue, Aug 09, 2005 at 11:24:40PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > Hmm. I have a patch for this, but now that it's ready, I wonder if it's
> > really needed. If I understand vacuum_set_xid_limits() correctly, it's
> > very difficult for the vacuumxid to be far behind the freeze limit.
>
> Umm ... they can be close together, or a billion XIDs apart, depending
> on whether the FREEZE option was used.

Sorry, my point was that vacuumxid is generally going to be higher than
freeze-xid, and where it isn't, a simple vacuum can't fix it.

But now that I think about it, maybe the point is that if a long-running
transaction (a billon-transactions old transaction?) was running when
the last database-wide vacuum was run, then vacuumxid is going to be
older than freeze-xid, so we may need a database-wide vacuum to fix that
even though the freeze-xid is not old enough.

Is that right?

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
We take risks not to escape from life, but to prevent life escaping from us.


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-10 17:33:32
Message-ID: 20050810173332.GA8752@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Updated this patch again:

> > - vacuum_cost_delay and vacuum_cost_limit can be set per table, as well
> > as globally with autovacuum_vacuum_cost_{limit,delay}
> >
> > - pgstat is reset if recovery is required
> >
> > - pgstat reset at postmaster start is disabled by default
>
> - Xid-wraparound VACUUM is now FREEZE without ANALYZE, iff the database
> has datallowconn=false or datistemplate=true

- A database-wide vacuum is also issued if the vacuumxid is found to be
very old.

Note that I had to add datvacuumxid to the pg_database flat file.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Ciencias políticas es la ciencia de entender por qué
los políticos actúan como lo hacen" (netfunny.com)

Attachment Content-Type Size
autovac-three-3.patch text/plain 37.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-11 21:13:15
Message-ID: 21280.1123794795@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> Updated this patch again:

> - vacuum_cost_delay and vacuum_cost_limit can be set per table, as well
> as globally with autovacuum_vacuum_cost_{limit,delay}
>
> - pgstat is reset if recovery is required
>
> - pgstat reset at postmaster start is disabled by default
>
> - Xid-wraparound VACUUM is now FREEZE without ANALYZE, iff the database
> has datallowconn=false or datistemplate=true
>
> - A database-wide vacuum is also issued if the vacuumxid is found to be
> very old.

Applied with minor tweaks --- mostly, fixing it so the custom cost
settings are applied for ANALYZE as well as VACUUM.

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-11 21:44:47
Message-ID: 20050811214447.GC28253@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Thu, Aug 11, 2005 at 05:13:15PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> > Updated this patch again:
>
> Applied with minor tweaks --- mostly, fixing it so the custom cost
> settings are applied for ANALYZE as well as VACUUM.

Ok, cool, thanks. I think this completes the autovacuum work I wanted
to do for 8.1. AFAIK the only thing that we are still badly missing is
the documentation update. (Matthew, if you are too busy to write it,
please let me know so I know I have to tackle it.)

For 8.2 my first priority (autovac-related) is to eliminate, or at least
alleviate, the need for database-wide vacuums, by keeping track of Xid
wraparound issues on a per-relation basis.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
Este mail se entrega garantizadamente 100% libre de sarcasmo.


From: Mark Wong <markw(at)osdl(dot)org>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-12 17:49:43
Message-ID: 200508121749.j7CHnDjA027522@smtp.osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

I thought I'd run a couple of tests to see if it would be helpful
against CVS from Aug 3, 2005.

Here's a run with autovacuum turned off:
http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/42/
5186.55 notpm

Autvacuum on with default settings:
http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/38/
5462.23 notpm

Would it help more to try a series of parameter changes?

Mark


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Mark Wong <markw(at)osdl(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-12 21:49:41
Message-ID: 20050812214941.GI16953@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Aug 12, 2005 at 10:49:43AM -0700, Mark Wong wrote:
> I thought I'd run a couple of tests to see if it would be helpful
> against CVS from Aug 3, 2005.
>
> Here's a run with autovacuum turned off:
> http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/42/
> 5186.55 notpm
>
> Autvacuum on with default settings:
> http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/38/
> 5462.23 notpm

Just noticed what seems to be a bug: in

http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/42/db/index_info.input

plot "index_info.data" using 1:2 title "i_customer" with lines, \
"index_info.data" using 1:2 title "i_orders" with lines, \
"index_info.data" using 1:3 title "pk_customer" with lines, \
"index_info.data" using 1:4 title "pk_district" with lines, \
"index_info.data" using 1:5 title "pk_item" with lines, \
"index_info.data" using 1:6 title "pk_new_order" with lines, \
"index_info.data" using 1:7 title "pk_order_line" with lines, \
"index_info.data" using 1:8 title "pk_orders" with lines, \
"index_info.data" using 1:9 title "pk_stock" with lines, \
"index_info.data" using 1:11 title "pk_warehouse" with lines

Notice how the subindexes are wrong ... I think it should be 1:3 for
i_orders, no? Apparently indexes_scan.data has the same problem.

It called my attention that the pk_warehouse index seems to have a very
different usage in both runs in index_info, but in indexes_scan they
seem similar.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Las mujeres son como hondas: mientras más resistencia tienen,
más lejos puedes llegar con ellas" (Jonas Nightingale, Leap of Faith)


From: Mark Wong <markw(at)osdl(dot)org>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-12 22:16:04
Message-ID: 200508122215.j7CMFYjA014884@smtp.osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, 12 Aug 2005 17:49:41 -0400
Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:

> On Fri, Aug 12, 2005 at 10:49:43AM -0700, Mark Wong wrote:
> > I thought I'd run a couple of tests to see if it would be helpful
> > against CVS from Aug 3, 2005.
> >
> > Here's a run with autovacuum turned off:
> > http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/42/
> > 5186.55 notpm
> >
> > Autvacuum on with default settings:
> > http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/38/
> > 5462.23 notpm
>
> Just noticed what seems to be a bug: in
>
> http://www.testing.osdl.org/projects/dbt2dev/results/dev4-015/42/db/index_info.input
>
> plot "index_info.data" using 1:2 title "i_customer" with lines, \
> "index_info.data" using 1:2 title "i_orders" with lines, \
> "index_info.data" using 1:3 title "pk_customer" with lines, \
> "index_info.data" using 1:4 title "pk_district" with lines, \
> "index_info.data" using 1:5 title "pk_item" with lines, \
> "index_info.data" using 1:6 title "pk_new_order" with lines, \
> "index_info.data" using 1:7 title "pk_order_line" with lines, \
> "index_info.data" using 1:8 title "pk_orders" with lines, \
> "index_info.data" using 1:9 title "pk_stock" with lines, \
> "index_info.data" using 1:11 title "pk_warehouse" with lines
>
> Notice how the subindexes are wrong ... I think it should be 1:3 for
> i_orders, no? Apparently indexes_scan.data has the same problem.

Whoops! I think I fixed it for real now and the charts should be
updated now. It was broken slightly more previously.

> It called my attention that the pk_warehouse index seems to have a very
> different usage in both runs in index_info, but in indexes_scan they
> seem similar.

Thanks,
Mark


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Mark Wong <markw(at)osdl(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-12 22:42:09
Message-ID: 20050812224209.GK16953@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Aug 12, 2005 at 03:16:04PM -0700, Mark Wong wrote:
> On Fri, 12 Aug 2005 17:49:41 -0400
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> > Notice how the subindexes are wrong ... I think it should be 1:3 for
> > i_orders, no? Apparently indexes_scan.data has the same problem.
>
> Whoops! I think I fixed it for real now and the charts should be
> updated now. It was broken slightly more previously.

Hmm, did you fix the 42 case only? The other one is broken too ...

Also, it seems the "tran_lock.out" file captured wrong input -- I think
you mean "WHERE transactionid IS NULL" in the query instead of "WHERE
transaction IS NULL".

I wonder what the big down-spikes (?) at minutes ~45 and ~85 correspond
to. Are those checkpoints? The IO vmstat chart would indicate that, I
think.

Anyway, it's interesting to see the performance go up with autovacuum
on. I certainly didn't expect that in this kind of test.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"No necesitamos banderas
No reconocemos fronteras" (Jorge González)


From: Mark Wong <markw(at)osdl(dot)org>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-12 22:49:57
Message-ID: 200508122249.j7CMnRjA017024@smtp.osdl.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, 12 Aug 2005 18:42:09 -0400
Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:

> On Fri, Aug 12, 2005 at 03:16:04PM -0700, Mark Wong wrote:
> > On Fri, 12 Aug 2005 17:49:41 -0400
> > Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> >
> > > Notice how the subindexes are wrong ... I think it should be 1:3 for
> > > i_orders, no? Apparently indexes_scan.data has the same problem.
> >
> > Whoops! I think I fixed it for real now and the charts should be
> > updated now. It was broken slightly more previously.
>
> Hmm, did you fix the 42 case only? The other one is broken too ...

The other dev4-015 cases should be fixed too.

> Also, it seems the "tran_lock.out" file captured wrong input -- I think
> you mean "WHERE transactionid IS NULL" in the query instead of "WHERE
> transaction IS NULL".

Hmm, ok I can try that in a future test run. I'm not very familiar with
this table, what's the difference between transaction and transactionid?

> I wonder what the big down-spikes (?) at minutes ~45 and ~85 correspond
> to. Are those checkpoints? The IO vmstat chart would indicate that, I
> think.

That's correct, those should be checkpoints.

> Anyway, it's interesting to see the performance go up with autovacuum
> on. I certainly didn't expect that in this kind of test.

I think in Mary's case it was hurting, but she's running the workload
dramatically different. I think she was planning to revisit that after
we sort out what's going on with the grouped WAL writes.

Mark


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Mark Wong <markw(at)osdl(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Autovacuum loose ends
Date: 2005-08-12 22:57:34
Message-ID: 20050812225734.GM16953@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Fri, Aug 12, 2005 at 03:49:57PM -0700, Mark Wong wrote:
> On Fri, 12 Aug 2005 18:42:09 -0400
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:

> > Also, it seems the "tran_lock.out" file captured wrong input -- I think
> > you mean "WHERE transactionid IS NULL" in the query instead of "WHERE
> > transaction IS NULL".
>
> Hmm, ok I can try that in a future test run. I'm not very familiar with
> this table, what's the difference between transaction and transactionid?

transaction is the Xid of the transaction holding or waiting for the
lock. transactionid is not null in the case where the lock is for a
TransactionId. I guess it depends on what do you want though -- now
that I think about it, capturing only transaction locks is very likely
not what you want.

http://developer.postgresql.org/docs/postgres/view-pg-locks.html

I wonder why do you have that condition though. I don't think
"transaction" can ever be NULL in that view.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Hay dos momentos en la vida de un hombre en los que no debería
especular: cuando puede permitírselo y cuando no puede" (Mark Twain)