Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E013D1337BBB for ; Thu, 24 Feb 2011 15:55:05 -0400 (AST) 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 79013-05 for ; Thu, 24 Feb 2011 19:54:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from asmtpout014.mac.com (asmtpout014.mac.com [17.148.16.89]) by mail.postgresql.org (Postfix) with ESMTP id 4CB831337B61 for ; Thu, 24 Feb 2011 15:54:58 -0400 (AST) MIME-version: 1.0 Content-type: multipart/alternative; boundary="Boundary_(ID_O2V2ePrPv0L4EVYFLIJKtw)" Received: from [192.168.1.34] (195-241-150-171.ip.telfort.nl [195.241.150.171]) by asmtp014.mac.com (Oracle Communications Messaging Exchange Server 7u4-20.01 64bit (built Nov 21 2010)) with ESMTPSA id <0LH500L3G0NHVQ20@asmtp014.mac.com> for pgsql-admin@postgresql.org; Thu, 24 Feb 2011 11:54:57 -0800 (PST) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15,1.0.148,0.0.0000 definitions=2011-02-24_08:2011-02-24, 2011-02-24, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1012030000 definitions=main-1102240081 Cc: "pgsql-admin@postgresql.org" Message-id: <1BFCE64D-F2CD-40DF-BAAA-EECDA5FC3F5D@mac.com> From: Frank Heikens To: "scorpdaddy@hotmail.com" In-reply-to: Subject: Re: sequence numbers under pg concurrence model Date: Thu, 24 Feb 2011 20:54:53 +0100 References: X-Mailer: Apple Mail (2.936) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.021 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1.929, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/215 X-Sequence-Number: 36854 --Boundary_(ID_O2V2ePrPv0L4EVYFLIJKtw) Content-type: text/plain; CHARSET=US-ASCII; format=flowed; delsp=yes Content-transfer-encoding: 7BIT Op 24 feb 2011, om 20:49 heeft scorpdaddy@hotmail.com het volgende geschreven: > What is the expected behaviour of sequence numbers under pg > concurrence model? From the manual: Important: To avoid blocking concurrent transactions that obtain numbers from the same sequence, a nextval operation is never rolled back; that is, once a value has been fetched it is considered used, even if the transaction that did the nextval later aborts. This means that aborted transactions might leave unused "holes" in the sequence of assigned values. setval operations are never rolled back, either. http://www.postgresql.org/docs/current/static/functions-sequence.html > E.g. Uncommitted transaction 1 in progress has inserted 5 tuples > into table foo. Meanwhile uncommitted transaction 2 in progress > inserts 100 tuples into table foo. If the sequence number for the > pk started at 1000 before these transactions, what are the sequence > numbers for transaction 1, 2, and the final sequence number if they > both commit? One rollback's? Both rollback? One hangs open while > the other commits? One hang and one rollback's? > Frank Heikens --Boundary_(ID_O2V2ePrPv0L4EVYFLIJKtw) Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: quoted-printable
Op 24 feb 2011, = om 20:49 heeft scorpdaddy@hotmail.com het = volgende geschreven:

What is = the expected behaviour of sequence numbers under pg concurrence model? =

=46rom the manual:
nextval operation is never = rolled back; that is, once a value has been fetched it is considered = used, even if the transaction that did the nextval later aborts. This = means that aborted transactions might leave unused "holes" in the sequence of assigned = values. 


E.g. =  Uncommitted transaction 1 in progress has inserted 5 tuples into = table foo.  Meanwhile uncommitted transaction 2 in progress inserts = 100 tuples into table foo.  If the sequence number for the pk = started at 1000 before these transactions, what are the sequence numbers = for transaction 1, 2, and the final sequence number if they both commit? =  One rollback's?  Both rollback? One hangs open while the = other commits?  One hang and one = rollback's?


Frank Heikens



= --Boundary_(ID_O2V2ePrPv0L4EVYFLIJKtw)--