Re: CPU-intensive autovacuuming

From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: Phil Endecott <spam_from_postgresql_general(at)chezphil(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CPU-intensive autovacuuming
Date: 2005-06-07 00:33:26
Message-ID: 42A4EB56.5080905@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Phil Endecott wrote:

> Following up on my own post from last night:
>
> > Could it be that there is some code in autovacuum that is O(n^2) in
> > the number of tables?
>
> Browsing the code using webcvs, I have found this:
>
> for (j = 0; j < PQntuples(res); j++)
> {
> tbl_elem = DLGetHead(dbs->table_list);
> while (tbl_elem != NULL)
> {
>
> I haven't really tried to understand what is going on in here, but it
> does look like it is getting the result of the "pg_class join stats"
> query and then matching it up against its internal list of tables
> using nested loops, which is undoubtedly O(n^2) in the number of tables.
>
> Have I correctly understood what is going on here?

Indeed you have. I have head a few similar reports but perhaps none as
bad as yours. One person put a small sleep value so that it doesn't
spin so tight. You could also just up the sleep delay so that it
doesn't do this work quite so often. No other quick suggestions.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ouyang_jw 2005-06-07 01:42:12 how to get sequence list ?
Previous Message Dianne Yumul 2005-06-06 22:24:35 Postgresql fails to start?

Browse pgsql-hackers by date

  From Date Subject
Next Message a_ogawa 2005-06-07 00:35:56 Re: [HACKERS] regexp_replace
Previous Message Bruce Momjian 2005-06-07 00:26:36 Re: unicode upper/lower functions