...Well, why not just use the Sequence?
It shouldn't be too difficult to write some triggers that make something closer to autoincrement. It probably won't work very well if there are lots of concurrent updates though. You can either lock the table with the column exclusively and then find the largest value and then use that value plus one. Don't use max for this. Make an index on the autoincrement column and use order by and limit 1 to get the largest value. The other option is to keep the sequence value in other table. You can use select for update to update it. You will want to vacuum this table often enough that it will stay on one page.
Is there really such a performance hit when calling a trigger?
In Oracle, one usually does such a thing, as there is no such nice workaround
as SERIAL.
Hmm, I am still thinking about a special kinf of SERIAL, maybe called
TRIGGERED_SERIAL which creates a trigger instead of a DEFAULT.
Cheers, Dani
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html