Re: [GENERAL] using ID as a key - Mailing list pgsql-general

From Marc Tardif
Subject Re: [GENERAL] using ID as a key
Date
Msg-id Pine.BSF.4.10.10002041732490.74743-100000@server.b0x.com
Whole thread Raw
In response to Re: [GENERAL] using ID as a key  (Ed Loehr <eloehr@austin.rr.com>)
List pgsql-general
I've been using OID's for a while now, and I haven't had any trouble at
all so far. Because this is an active database, it has been important to
keep the current data intact. Nevertheless, I have managed to keep
everything in order even to the last OID. To dump with oid's, simply add
the -o flag to pg_dump (as explained in the pg_dump manpage).

In my situation, I particularly appreciate OID's because they have little
overhead and they simply do the job. More specifically, they come in handy
for creating a fulltextindex, which I recommend you take a look at in the
contributions.

Although I don't completely agree with Ed Loehr, he does have a point
though. Keeping track of OID's can be more complicated than using an id
field in a table. The major problem being that you can't change an OID and
you can't predict OID's either. As Bruce was telling me, OID's are
gathered in batches of 100 by each backend, so you never really know what
you'll end up with. Regardless of these obstacles, it is not wrong to use
OID's and you should be open to this option.

My 2 cents,
Marc

On Fri, 4 Feb 2000, Ed Loehr wrote:

> Bruce Momjian wrote:
> >
> > > Marc Tardif wrote:
> > > >
> > > > I recommend you read Momjian's online book, very informative and provides
> > > > all the necessary information about using various kinds of id's:
> > > > http://www.postgresql.org/docs/aw_pgsql_book/index.html
> > >
> > > In glancing at Momjian's stuff on this just now, I noticed the book
> > > could leave the first-time reader with the impression that both OIDs
> > > and sequences (ie, SERIAL) are viable choices for use as primary keys
> > > (unintentionally?).  Sequences and SERIALs are not mentioned until
> > > after a long example of how to do primary keys with OIDs.
> >
> > Don't glance.  Read the whole chapter.  It will be clear.  If people get
> > the wrong impression by reading part of the chapter, well, it's their
> > fault.
>
> What's clear is this is a really lousy answer to a specific question,
> and that you're not too open to feedback on the book.
>
> The answer, as Momjian himself points out in the section right after
> the one in which he shows you how to use OIDs as primary keys, is that
> OIDs are NOT DUMPED AT BACKUP TIME by default.  That would mean your
> newly-dumped database would be corrupt upon creation if you used
> OIDs.  Most people wouldn't appreciate that very much.  Alas, he does
> mention that you may twiddle this flag to have OIDs
> dumped...uh...er...nevermind...that documentation doesn't exist yet.
> Give me a break.
>
> The book leads people astray in this regard, Mr. Momjian.  If you'd
> want to spend time reading posts from people requesting help in
> salvaging databases corrupted by their book-inspired error, rather
> than taking a hint on a confusing presentation, that's your choice.
>
> Cheers,
> Ed Loehr
>


pgsql-general by date:

Previous
From: Simon Drabble
Date:
Subject: Re: [GENERAL] using ID as a key
Next
From:
Date:
Subject: Re: [GENERAL] using ID as a key