473,467 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Understanding pg_autovacuum CPU Usage

I've been using pg_autovacuum on a largish postgres installation
successfully for several weeks, now. I know that pg_autovacuum has no
facility for monitoring the system to know whether any particular time
is a good one for it to do it's thing, but I'm wondering what the
occasional episodes of 99.9% CPU usage (as reported by top) are.

I keep a pg_autovacuum.log, and when the spikes start, often nothing is
written to the log. And what ends up being written has been of varying
amounts of potential strain. Frequently, the tables involved are
smallish. So I'm wondering: does the CPU usage correspond to any time
pg_autovacuum arouses from its sleep state and begins looking for what
it ought to do?

Any thoughts?

-tfo
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #1
5 1685
Thomas F.O'Connell wrote:
I've been using pg_autovacuum on a largish postgres installation
successfully for several weeks, now. I know that pg_autovacuum has no
facility for monitoring the system to know whether any particular time
is a good one for it to do it's thing, but I'm wondering what the
occasional episodes of 99.9% CPU usage (as reported by top) are.

I keep a pg_autovacuum.log, and when the spikes start, often nothing is
written to the log. And what ends up being written has been of varying
amounts of potential strain. Frequently, the tables involved are
smallish. So I'm wondering: does the CPU usage correspond to any time
pg_autovacuum arouses from its sleep state and begins looking for what
it ought to do?

Any thoughts?


This is the first report I have heard of pg_autovacuum causing cpu usage
spikes. When pg_autovacuum wakes up, it loops through all the databases
checking for recent activity and decides if it is time to do something.
I would think that pg_autovacuum wouldn't use much CPU during this
time since it would be waiting a lot on connection startup and query
responses from the server. I suppose that it could use a noticeable
amount of CPU if you had a lot of databases for it to loop through and a
very small connection time. Are you using pooled connections? Also is
this 7.4.x or 8.0 beta?

Can you hook up a debugger and see what it's doing during the CPU spikes?

Thanks for the report,

Matthew
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2

On Sep 1, 2004, at 5:09 PM, Matthew T. O'Connor wrote:
This is the first report I have heard of pg_autovacuum causing cpu
usage spikes. When pg_autovacuum wakes up, it loops through all the
databases checking for recent activity and decides if it is time to do
something. I would think that pg_autovacuum wouldn't use much CPU
during this time since it would be waiting a lot on connection startup
and query responses from the server. I suppose that it could use a
noticeable amount of CPU if you had a lot of databases for it to loop
through and a very small connection time.
Well, I don't have a lot of databases, but I do have tens of thousands
of tables, many of which have hundreds of thousands of rows. I don't
know if that plays into things.
Are you using pooled connections?
No.
Also is this 7.4.x or 8.0 beta?
Oops. Sorry. It's 7.4.5, specifically.
Can you hook up a debugger and see what it's doing during the CPU
spikes?


That's going to be a little tricky because it's a production
environment. So far, the spikes haven't hurt too much because they
don't last very long. I'll see if I can get anything similar to occur
in our development environment.

-tfo
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #3
Thomas F.O'Connell wrote:
Well, I don't have a lot of databases, but I do have tens of thousands
of tables, many of which have hundreds of thousands of rows. I don't
know if that plays into things.
Number of rows is irrelevant, but the number of tables might not be. It
could be that the process of checking it's list of tables against the
server might be slow when used with lots of tables. Does this cpu spike
happen every other loop? If so then that is the culprit. Editing
pg_autovacuum.c and changing:

#define UPDATE_INTERVAL 2

to some higher value. The default UPDATE_INTERVAL tells pg_autovacuum
to check for added / removed tables every 2 loops.
Oops. Sorry. It's 7.4.5, specifically.


Ok
Can you hook up a debugger and see what it's doing during the CPU spikes?


That's going to be a little tricky because it's a production
environment. So far, the spikes haven't hurt too much because they don't
last very long. I'll see if I can get anything similar to occur in our
development environment.


Try the simple recompile with the larger update interval first and see
if that's the problem.

Matthew
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #4

On Sep 1, 2004, at 10:27 PM, Matthew T. O'Connor wrote:
Number of rows is irrelevant, but the number of tables might not be.
It could be that the process of checking it's list of tables against
the server might be slow when used with lots of tables. Does this cpu
spike happen every other loop?
Is there an easy way to determine if it's happening every other loop?
Try the simple recompile with the larger update interval first and see
if that's the problem.


How difficult would it be to make this a command-line argument if it
turns out to be a run-time issue?

Thanks for the input.

-tfo
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #5
Thomas F.O'Connell wrote:

On Sep 1, 2004, at 10:27 PM, Matthew T. O'Connor wrote:
Number of rows is irrelevant, but the number of tables might not be.
It could be that the process of checking it's list of tables against
the server might be slow when used with lots of tables. Does this cpu
spike happen every other loop?


Is there an easy way to determine if it's happening every other loop?


Yes, if you are running pg_autovacuum with a debug setting >= 1 it will
write out a message at the end of every loop.
Try the simple recompile with the larger update interval first and see
if that's the problem.


How difficult would it be to make this a command-line argument if it
turns out to be a run-time issue?


Very Easy.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Adam Kavan | last post by:
I decided to try pg_autovacuum and am having a problem. It never analyzes or vacuums. I looked at the code and had it display printf("%s,%s,%s\n",PQgetvalue(res, j, PQfnumber(res,...
5
by: Frank van Vugt | last post by:
Hi, I noticed that when using the single commandline: drop database <name>; create database <name>; this sometimes fails due to a pg_autovacuum process running on the background. When...
0
by: Brian Hirt | last post by:
Hello, I've run across a pretty serious problem with pg_autovacuum. pg_autovacuum looses track of any table that's ever been truncated (possibly other situations too). When i truncate a table...
3
by: Markus Wollny | last post by:
Hi! I haven't found anything in terms of startup- and check-scripts for pg_autovacuum yet; usually I like to have some sort of mechanism to check if some daemon is running and restart it if it...
4
by: David Wheeler | last post by:
4.8-STABLE FreeBSD 4.8-STABLE i386 sahlins# cd postgresql-7.4.2/contrib/pg_autovacuum sahlins# make "../../src/Makefile.global", line 38: Missing dependency operator...
3
by: Brian Hirt | last post by:
I've having a strange issue with pg_autovacuum. I have a table with about 4 million rows in 20,000 pages. autovacuum likes to vacuum and/or analyze it every 45 minutes or so, but it probably...
2
by: Peter Haworth | last post by:
Is it possible/safe to compile the latest version of pg_autovacuum, and use it with a 7.2.4 postmaster? I know the better solution would be to upgrade everything, but that involves a lot of work...
7
by: Thomas F.O'Connell | last post by:
I'm about to try to implement a simple pg_autovacuum script that can be used in conjunction with or integrated entirely with the contrib start-scripts for postgres. I just want to check that what...
2
by: Oliver Elphick | last post by:
I get this in the logs for every database open by pg_autovacuum: Sep 1 14:02:45 cerberus pg_autovacuum: nss_ldap: could not connect to any LDAP server as (null) - Can't contact LDAP server ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.