X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 98F4631029A for ; Fri, 27 Jun 2003 14:35:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 86169-02 for ; Fri, 27 Jun 2003 11:35:42 -0300 (ADT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by svr1.postgresql.org (Postfix) with ESMTP id 63D223102DE for ; Fri, 27 Jun 2003 11:35:40 -0300 (ADT) Received: from [212.227.126.155] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 19VuKD-0005D7-00 for pgsql-sql@postgresql.org; Fri, 27 Jun 2003 16:35:41 +0200 Received: from [217.230.196.123] (helo=ecologic.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 19VuKD-0005vM-00 for pgsql-sql@postgresql.org; Fri, 27 Jun 2003 16:35:41 +0200 Message-ID: <3EFC5638.5040406@ecologic.de> Date: Fri, 27 Jun 2003 16:35:36 +0200 From: Dani Oderbolz User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Change the behaviour of the SERIAL "Type" References: <3EFC0413.7090006@ecologic.de> <20030627142635.GB15269@wolff.to> In-Reply-To: <20030627142635.GB15269@wolff.to> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200306/316 X-Sequence-Number: 14074 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