[Nitro] question about postgresql.rb && last_insert_id and insert_sql
john at oxyliquit.de
Tue Oct 24 15:34:15 EDT 2006
> 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.
More information about the Nitro-general