Bo Lorentsen <[EMAIL PROTECTED]> writes:
> I use normal tabel ID (SERIAL and BIGSERIAL) all over the place for FK 
> constaints, but I use OID in one special situation. When I insert a 
> single row into a table, I like my low level code to be kompatible with 
> mysql ( mysql_insert_id ), and fetch the row that I just inserted. This 
> I do by using the PGoidValue function, and then select the row by the 
> oid. This works quite nice .... but when a table get large, it become a 
> big search (seq scan)  so I have added an index on oid's on the table 
> where I use this trick, and this have helper :-)

The thing you have to worry about is the possibility of duplicate OIDs
once your DB has been running long enough for the OID counter to wrap
around (2^32 OIDs).  You should make sure that index is specifically
declared as UNIQUE, so that any attempt to insert a duplicate OID will
fail.  That might be enough for you, or you might want to add logic to
your application to retry automatically after such a failure.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to