Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by hub.org (8.10.1/8.10.1) with ESMTP id e93JApG08527 for ; Tue, 3 Oct 2000 15:10:51 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.0/8.11.0) with ESMTP id e93JAkB29678; Tue, 3 Oct 2000 15:10:46 -0400 (EDT) To: josh@agliodbs.com cc: sqllist , Jeff MacDonald Subject: Re: OID Perfomance - Object-Relational databases In-reply-to: <39DA03EA.7A1027E8@agliodbs.com> References: <39DA03EA.7A1027E8@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Tue, 03 Oct 2000 09:06:02 -0700" Date: Tue, 03 Oct 2000 15:10:45 -0400 Message-ID: <29675.970600245@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200010/40 Josh Berkus 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