Re: Change the behaviour of the SERIAL "Type"
От | Dani Oderbolz |
---|---|
Тема | Re: Change the behaviour of the SERIAL "Type" |
Дата | |
Msg-id | 3EFC5638.5040406@ecologic.de обсуждение исходный текст |
Ответ на | Re: Change the behaviour of the SERIAL "Type" (Bruno Wolff III <bruno@wolff.to>) |
Ответы |
Re: Change the behaviour of the SERIAL "Type"
Re: Change the behaviour of the SERIAL "Type" |
Список | 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 по дате отправления: