> yep:
> lock "tablename.colname.val=1"
> select count(*) from tablename where colname=1
> If no rows, insert, else update.
> (dunno if the locks would scale to a scenario with hundreds
> of concurrent inserts - how many user locks max?).
I don't see problem here - just a few bytes in shmem for
key. Auxiliary table would keep refcounters for keys.
> Why wouldn't it work with serializable isolevel?
Because of selects see old database snapshot and so you
wouldn't see key inserted+committed by concurrent tx.
Vadim