Re: newbie ?'s

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Cc: "Clayton Vernon" <cvernon(at)enron(dot)com>
Subject: Re: newbie ?'s
Date: 2001-04-26 13:59:41
Message-ID: 00a601c0ce59$2484d470$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

3) I've been told PostgreSQL databases must be periodically "rebuilt" so to
speak, ("vacuumed"). Is this easy to do on-the-fly? Rapid? Or, does the db
need to go down awhile?

Not so much rebuilt, but just cleaned up. My understanding is that deleted
records (and outdated copies of UPDATEd records) are removed, and statistics
are compiled that helps the planner determine the best way to fill your
queries. It's pretty easy to do on the fly... VACUUM; or better yet VACUUM
ANALYZE; from the SQL prompt, or 'vacuumdb' from the command line.

This can be done on a running database, but I'd recommend setting up a cron
job to do it when the database is not very busy (i.e. 4AM or some other
off-hour). The operational time depends on the size of your database; our
relatively small databases (no more than 60K records in a given table) only
take a few minutes. Not quite rapid, but not terribly painful either.

4) I can't find anything yet in the docs on on-the-fly backups of the db.
Can you simply copy the directory, or will this not have integrity? What is
the best strategy to study for backing up of databases that may be in use
7x24?

You'll want to look for the pg_dump utility. There's plenty of documentation
on this (including a nice man page), so I won't go into detail. But you can
run this on a cron job as well. pg_dump should back up the entire database,
including the schema, although it has options to dump data or schema only.
It even does it in a nice text format, so you can even go in with your
favorite text editor and modify the schema or do whatever you want. When you
need to restore, just pipe the pg_dump'ed file into psql and your have your
database. Like VACUUM, you can run pg_dump at any time from the command
line.

I'll let those wiser and more knowledgable answer the other questions...

Greg

In response to

  • newbie ?'s at 2001-04-24 15:03:22 from Clayton Vernon

Browse pgsql-general by date

  From Date Subject
Next Message Vince Vielhaber 2001-04-26 14:00:42 Re: [GENERAL] Re: Hardcopy docs available
Previous Message Bryan Field-Elliot 2001-04-26 13:50:41 How to estimate disk space requirements?