[Nitro] question about postgresql.rb && last_insert_id and insert_sql

transfire at gmail.com transfire at gmail.com
Tue Oct 24 19:20:12 EDT 2006


Jonathan Buch wrote:
> Hi,
>
> > Jonathan Buch wrote:
> > > The problem here is, that you have no way of telling after the insert,
> > > which oid has been selected.  The frontend has to know this, to identify
> > > the object.
> >
> > If run in the same transaction as the insert, I'm pretty sure you can
> > do a select query on the index sequence and thus get the new id.
>
> Which would defeat the original purpose of speeding it up by using a
> single query.  Also, like I said, I'm pretty sure that there are race
> conditions when doing that...
> Well, that is, unless one is using transaction (not sure which locking
> level one has to use then, since one has to verify that nothing has been
> written to the same table while the insert transaction has the lock).
> So this transaction would have to block this totally while it's
> inserting...  Not sure if that'd have impact on performance as well.
>
> When getting the next oid beforehand, this is fixed and other inserts
> can't get the same oid.

True. Definitely a better way to do it.
 
T.



More information about the Nitro-general mailing list