Re: select/update performance? - Mailing list pgsql-general

From Bjørn T Johansen
Subject Re: select/update performance?
Date
Msg-id 1068025757.12114.22.camel@pgsqlsrv.havleik.no
Whole thread Raw
In response to Re: select/update performance?  (Rob Fielding <rob@dsvr.net>)
Responses Re: select/update performance?
Re: select/update performance?
Re: select/update performance?
List pgsql-general
Yes, but the table in question have 3 PK and only one that needs this
"sequence" so I just thought instead of getting holes in the IDs I just
manually handle this counter somehow.. Not a big deal but... :)


BTJ

On Wed, 2003-11-05 at 10:42, Rob Fielding wrote:
> Bjørn T Johansen wrote:
> > I need to maintain a manually counter for an id-field, but I can do this
> > two ways. Either make a counter table (which means one select and one
> > update) or just selecting the largest id from existing table and
> > increment by one (just one select + one table lock). Which one is
> > fastest?
>
> Is would be better to create a SEQUENCE and simply call nextval on it.
> Then you are assured that you'll get a unique sequence when working in a
> concurrent environment.
>
> It would also be guaranteed faster than interrogating tables.
>
> Hope this helps,


pgsql-general by date:

Previous
From: Rob Fielding
Date:
Subject: Re: select/update performance?
Next
From: Csaba Nagy
Date:
Subject: Re: select/update performance?