Re: Change the behaviour of the SERIAL "Type" - Mailing list pgsql-sql

From Dani Oderbolz
Subject Re: Change the behaviour of the SERIAL "Type"
Date
Msg-id 3EFC5638.5040406@ecologic.de
Whole thread Raw
In response to Re: Change the behaviour of the SERIAL "Type"  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: Change the behaviour of the SERIAL "Type"
Re: Change the behaviour of the SERIAL "Type"
List pgsql-sql
Bruno Wolff III wrote:

> ...
>
>
>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.
>
Well, why not just use the Sequence?
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




pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Change the behaviour of the SERIAL "Type"
Next
From: Rod Taylor
Date:
Subject: Re: Change the behaviour of the SERIAL "Type"