Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 9AE531337B5D for ; Thu, 16 Sep 2010 21:04:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 54212-03 for ; Fri, 17 Sep 2010 00:04:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) by mail.postgresql.org (Postfix) with ESMTP id 30B3E1337B43 for ; Thu, 16 Sep 2010 21:04:19 -0300 (ADT) Received: by qwh6 with SMTP id 6so1365084qwh.19 for ; Thu, 16 Sep 2010 17:04:19 -0700 (PDT) Received: by 10.220.168.213 with SMTP id v21mr2587492vcy.274.1284681859170; Thu, 16 Sep 2010 17:04:19 -0700 (PDT) Received: from Craig-Jamess-MacBook-Pro.local (wsip-70-167-124-126.sd.sd.cox.net [70.167.124.126]) by mx.google.com with ESMTPS id j34sm1732843vcs.28.2010.09.16.17.04.17 (version=SSLv3 cipher=RC4-MD5); Thu, 16 Sep 2010 17:04:18 -0700 (PDT) Message-ID: <4C92B080.3080800@emolecules.com> Date: Thu, 16 Sep 2010 17:04:16 -0700 From: Craig James User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: incrementing updates and locks References: <4C92A2F8.2050209@emolecules.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201009/95 X-Sequence-Number: 35639 On 9/16/10 4:17 PM, Aras Angelo wrote: > Daniel, Craig > > The gaps are not really expected. It is set once only. > Its about printing packing slips for ecommerce orders. We have the ORDER ID sequence, but so many different stations are accessing these orders, if my station print the next 100 orders from the que, id like to give them values starting from MAX(print_number_sequence so far) AND +1, +2, +3, .... +100. > > I hope this clears it better. I think a sequence can work. My concern was performance, as in the actual programming LOOP, querying the max field, assigning the row number, reissuing the max field. A sequence i guess, would perform better than a regular table index? Sequences are very fast. Just do something like this: update mytable set order_id = nextval('order_id_seq') where ... Using this technique, you will only get gaps in the sequence if something goes wrong and the transaction is rolled back. But given what you have told us about your application, it is probably not very important if a few ORDER ID numbers are missing. Craig > On Thu, Sep 16, 2010 at 4:06 PM, Craig James > wrote: > > On 9/16/10 3:54 PM, Aras Angelo wrote: > > Hello All > > I have a column in my table which is incrementally updated. > > > Try to give us more details... > > Does the column need have contiguous values or are "gaps" ok? That is, does it have to be 1,2,3,4,...,N-1,N or is it ok to have something like 1,3,4,7,...,M (where M>N) for N rows? > > Is the value updated every time the row is changed, or is it set once only? > > If gaps are OK, then a sequence is a simple answer. > > Craig > > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org ) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > >