From: Tom Lane <tgl@sss.pgh.pa.us>
To: josh@agliodbs.com
Cc: sqllist <pgsql-sql@postgresql.org>
Cc: Jeff MacDonald <jeff@pgsql.com>
Subject: Re: OID Perfomance - Object-Relational databases
Date: Tue, 03 Oct 2000 15:10:45 -0400
Message-ID: <29675.970600245@sss.pgh.pa.us> (raw)
In-Reply-To: <39DA03EA.7A1027E8@agliodbs.com>
References: <39DA03EA.7A1027E8@agliodbs.com>
Josh Berkus <josh@agliodbs.com> writes:
> 1. Is there a performance loss on searches and joins when I use the OID
> as a liniking field as opposed to a SERIAL column?
> 2. Can I define my own index on the OIDs of a table?
There is absolutely no magic about OIDs, except that the system insists
on adding one to every row you store. In particular, they don't offer
any magic fast way to find a tuple. If you want fast retrieval by OID
in a particular table then you *MUST* define an index on the OID column,
like so:
CREATE TABLE foo ( ... );
CREATE INDEX foo_oid_index ON foo (oid);
The performance of an index on OID will be indistinguishable from the
performance of an index on an int4 or serial column.
By and large I'd recommend using a serial column in preference to OIDs,
though, for two reasons:
1. dump/restore is more practical that way (don't have to worry about
saving/reloading OIDs).
2. counter overflow problems hit you only per-table, not
per-installation.
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, jeff@pgsql.com
Subject: Re: OID Perfomance - Object-Relational databases
In-Reply-To: <29675.970600245@sss.pgh.pa.us>
References: <39DA03EA.7A1027E8@agliodbs.com> <29675.970600245@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