pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedA few misc. questions.
4+ messages / 4 participants
[nested] [flat]
* A few misc. questions.
@ 2000-05-25 23:45 Rainer Mager <rmager@vgkk.com>
0 siblings, 1 reply; 4+ messages in thread
From: Rainer Mager @ 2000-05-25 23:45 UTC (permalink / raw)
To: pgsql-admin
Hi all,
I have a few miscellaneous questions. If anyone has any ideas I'd
appreciate hearing them.
1. What happens when the primary key index runs out. That is, if we use an
INT(4) for a key and we create and delete enough to reach that number then
what happens?
2. Does anyone one know a standard SQL method (that works with Postgres) to
retrieve the primary key of a newly INSERTed record? We've found one way but
it will not work with order databases since it relies on reading data from
the sequence tables.
3. Does anyone know of any way to perform a database backup/synchronization
that somehow does its work when the database is otherwise not busy? Which is
preferred, backing up the PG files or doing some sort of sync?
4. Does anyone have any advice on how often to run VACUUM? Any rules of
thumb, etc?
Thanks,
--Rainer
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: A few misc. questions.
@ 2000-05-26 08:10 Nicolas Huillard <nhuillard@ghs.fr>
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Huillard @ 2000-05-26 08:10 UTC (permalink / raw)
To: 'Rainer Mager' <rmager@vgkk.com>; pgsql-admin
1. using unsigned int(4), it will take 137 years, inserting one record a second, to reach MAXINT. That's not an issue, and haven't been handled.
2. Use the curval() function, which returns exactly what you want, and is far better than reading the sequence table (I don't know if it's standard : check the doc)
3. The only way is to pg_dump/pg_dump_all. Don't rely on backing up the database's files : they're almost in-memory and not sync'ed.
Postgres 7.0 has a query logging facility. Maybe someone can explain if it can be used as a replication tool ?
4. Daily, using this little script (/etc/cron.daily/postgresql) :
**************************************
#!/bin/sh
su postgres -c 'psql -t -c "select datname from pg_database order by datname;" template1 | xargs -n 1 psql -q -c "vacuum analyze;"'
**************************************
Maybe it is integrated in the 7.0 RPM ? If not, I think it should.
Nicolas Huillard
-----Message d'origine-----
De: Rainer Mager [SMTP:rmager@vgkk.com]
Date: vendredi 26 mai 2000 01:46
À: pgsql-admin@postgresql.org
Objet: [ADMIN] A few misc. questions.
Hi all,
I have a few miscellaneous questions. If anyone has any ideas I'd
appreciate hearing them.
1. What happens when the primary key index runs out. That is, if we use an
INT(4) for a key and we create and delete enough to reach that number then
what happens?
2. Does anyone one know a standard SQL method (that works with Postgres) to
retrieve the primary key of a newly INSERTed record? We've found one way but
it will not work with order databases since it relies on reading data from
the sequence tables.
3. Does anyone know of any way to perform a database backup/synchronization
that somehow does its work when the database is otherwise not busy? Which is
preferred, backing up the PG files or doing some sort of sync?
4. Does anyone have any advice on how often to run VACUUM? Any rules of
thumb, etc?
Thanks,
--Rainer
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: A few misc. questions.
@ 2000-05-26 14:15 Peter Eisentraut <e99re41@DoCS.UU.SE>
parent: Rainer Mager <rmager@vgkk.com>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Eisentraut @ 2000-05-26 14:15 UTC (permalink / raw)
To: Rainer Mager <rmager@vgkk.com>; +Cc: pgsql-admin
On Fri, 26 May 2000, Rainer Mager wrote:
> 1. What happens when the primary key index runs out. That is, if we use an
> INT(4) for a key and we create and delete enough to reach that number then
> what happens?
If you are talking about serial values, then you'll get an error.
Otherwise it's of course up to you what you do with your primary keys.
Eventually we'll move to int8 for serial probably.
> 2. Does anyone one know a standard SQL method (that works with Postgres) to
> retrieve the primary key of a newly INSERTed record? We've found one way but
> it will not work with order databases since it relies on reading data from
> the sequence tables.
Again, what you do with your primary keys is up to you. Ideally you won't
need to retrieve the primary key value because you know what you just
inserted. If you are talking about serial, then the answer is there isn't
one because serial isn't SQL. But as someone already said, the curval
function will do.
> 3. Does anyone know of any way to perform a database backup/synchronization
> that somehow does its work when the database is otherwise not busy? Which is
> preferred, backing up the PG files or doing some sort of sync?
For backup use pg_dump, for synchronization you're currently out of luck.
> 4. Does anyone have any advice on how often to run VACUUM? Any rules of
> thumb, etc?
If there's a lot of write activity in your database, nightly might be a
good idea. Otherwise less often.
--
Peter Eisentraut Sernanders väg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: A few misc. questions.
@ 2000-05-27 07:32 Ragnar Kjørstad <postgres@ragnark.vestdata.no>
parent: Peter Eisentraut <e99re41@DoCS.UU.SE>
0 siblings, 0 replies; 4+ messages in thread
From: Ragnar Kjørstad @ 2000-05-27 07:32 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Rainer Mager <rmager@vgkk.com>; pgsql-admin
On Fri, May 26, 2000 at 04:15:31PM +0200, Peter Eisentraut wrote:
> On Fri, 26 May 2000, Rainer Mager wrote:
>
> > 2. Does anyone one know a standard SQL method (that works with Postgres) to
> > retrieve the primary key of a newly INSERTed record? We've found one way but
> > it will not work with order databases since it relies on reading data from
> > the sequence tables.
>
> Again, what you do with your primary keys is up to you. Ideally you won't
> need to retrieve the primary key value because you know what you just
> inserted. If you are talking about serial, then the answer is there isn't
> one because serial isn't SQL. But as someone already said, the curval
> function will do.
Another approach is something like this:
pkey=sql("select nextval('some-sequence')")
sql("insert into table values ($pkey, $data)")
--
Ragnar Kjørstad
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-05-27 07:32 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-05-25 23:45 A few misc. questions. Rainer Mager <rmager@vgkk.com>
2000-05-26 14:15 ` Peter Eisentraut <e99re41@DoCS.UU.SE>
2000-05-27 07:32 ` Ragnar Kjørstad <postgres@ragnark.vestdata.no>
2000-05-26 08:10 RE: A few misc. questions. Nicolas Huillard <nhuillard@ghs.fr>
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