Received: from smtp013.mail.yahoo.com (smtp013.mail.yahoo.com [216.136.173.57]) by mail.postgresql.org (8.11.3/8.11.1) with SMTP id f2NI6Gw08576 for ; Fri, 23 Mar 2001 13:06:29 -0500 (EST) (envelope-from janwieck@yahoo.com) Received: from pd95750ba.dip.t-dialin.net (HELO jupiter.jw.home) (217.87.80.186) by smtp.mail.vip.sc5.yahoo.com with SMTP; 23 Mar 2001 18:06:14 -0000 X-Apparently-From: Received: (from janwieck@localhost) by jupiter.jw.home (8.9.3/8.9.3) id NAA18725; Fri, 23 Mar 2001 13:09:49 -0500 From: Jan Wieck Message-Id: <200103231809.NAA18725@jupiter.jw.home> Subject: Re: creating "job numbers" In-Reply-To: <200103231747.MAA18525@jupiter.jw.home> from postgresql at "Mar 23, 2001 08:16:26 am" To: postgresql Date: Fri, 23 Mar 2001 13:09:49 -0500 (EST) CC: Jan Wieck , PgSQL-SQL X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200103/466 X-Sequence-Number: 2134 postgresql wrote: > Jan, > > Thanks, I must be missing something here. Bear with me, I am > trying to form an intelligent question. > > Using the serial data type... I don't understand when the backend > would skip a number. > If the db is assigning the number with the insert, then if two (or > more) clients are trying to insert into the db at the exact same time, > only those that are successful should get a number. I am trying to > envision a situation where two clients hit at the same time and > because of problem with the insert, one aborts and the serial data > number is skipped. I would have assumed that the aborted insert is > just skipped no harm done. Concurrency will not cause your transactions to abort. It's just if you do BEGIN; INSERT INTO ... ROLLBACK; that the generated sequence numbers don't get rolled back. So you might find job numbers 1, 2, 4 where 3 is missing because it's transaction aborted (explicit rollback or error during processing). The serial data type will never fill in those gaps. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com