From: Tom Lane <tgl@sss.pgh.pa.us>
To: Brian Cox <brian.cox@ca.com>
Cc: pgsql-general@postgresql.org
Subject: Re: query performance
Date: Wed, 23 Apr 2008 16:42:51 -0400
Message-ID: <16712.1208983371@sss.pgh.pa.us> (raw)
In-Reply-To: <480F8FFF.8080904@ca.com>
References: <480F8FFF.8080904@ca.com>
Brian Cox <brian.cox@ca.com> writes:
> I have a largish (pg_dump output is 4G) database. The query:
> select count(*) from some-table
> was taking 120 secs to report that there were 151,000+ rows.
> This seemed very slow. This db gets vacuum'd regularly (at least once
> per day). I also did a manual 'vacuum analyze', but after it completed,
> the query ran no faster. However, after dumping the database and
> recreating it from the backup, the same query takes 2 secs.
> Why the dramatic decrease?
Presumably, the table was really bloated (lots of unused space).
> Would 'vacuum full' have achieved the
> same performance improvements?
It would've compacted the table all right, but probably left the indexes
worse off.
> Is there anything else that needs to be done
> regularly to prevent this performance degradation?
I suspect that your FSM settings are too low, causing free space found
by VACUUM to be forgotten about. You might also need to consider
vacuuming more than once a day (there's a tradeoff between how often
you vacuum and how much FSM space you need).
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, brian.cox@ca.com
Subject: Re: query performance
In-Reply-To: <16712.1208983371@sss.pgh.pa.us>
References: <480F8FFF.8080904@ca.com> <16712.1208983371@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox