Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1F410636AB1 for ; Thu, 17 Sep 2009 12:06:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 35120-10 for ; Thu, 17 Sep 2009 15:05:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f188.google.com (mail-pz0-f188.google.com [209.85.222.188]) by mail.postgresql.org (Postfix) with ESMTP id 836D063363A for ; Thu, 17 Sep 2009 12:05:46 -0300 (ADT) Received: by pzk26 with SMTP id 26so91054pzk.27 for ; Thu, 17 Sep 2009 08:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=UU2PWS9LQTmJXRYkHRXxE3EypHtMmmsky+segIK/XJ4=; b=E+QUGS+D0xNt9TzITzeGUQOm/f51lM+2EKnLWW6PC39KCBs78Bjhjq736kcZSlhQnv XzPkyjW5VZp5Y6epq69A0Vf16LjX8maInmEW6FCU/WWUFlXRf0g7ewYweDZBwEjS0pFb j4YtyvgmGh8+8hFu6MAjhecxeBCI5tzadSU+8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=sJm5Ul0RuS+M/R4mTwFgIvtM86UbILrCRNsoHAiuPEsv5t81tJ8SFtPQtF41JQYJF/ VEkSPj3PNL8WvHS9DLbtxR9qomgz8FHu+qOn4+GJ2iJ1gGRC9D1btInh2TgUPlHa6XQ9 hOyQB3FOTf3wPFJwAMVz+vUvujgKxCWSPsS/w= Received: by 10.114.104.10 with SMTP id b10mr236368wac.36.1253199945384; Thu, 17 Sep 2009 08:05:45 -0700 (PDT) Received: from ?172.16.1.234? ([208.187.158.94]) by mx.google.com with ESMTPS id 20sm347214pxi.8.2009.09.17.08.05.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 17 Sep 2009 08:05:44 -0700 (PDT) Message-ID: <4AB2504F.1010405@gmail.com> Date: Thu, 17 Sep 2009 09:05:51 -0600 From: Rob Sargent User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: rawi CC: pgsql-sql@postgresql.org Subject: Re: Hibernate, web application and only one sequence for all primary keys References: <25490498.post@talk.nabble.com> <4AB23593.4090906@beecom.ch> <25491924.post@talk.nabble.com> In-Reply-To: <25491924.post@talk.nabble.com> 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=-2.041 tagged_above=-10 required=5 tests=AWL=0.558, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/79 X-Sequence-Number: 33144 Above all, do not fret about whether or not it is "cool to lose" some ids. There are plenty of integers; the ids need not be consecutive. I don't think Grails requires a single sequence source and I know hibernate does not. Hibernate will allow one to inject any sequence/id generator you wish to use (including one which generates UUIDs). rawi wrote: > Leo Mannhart wrote: > >> Caveat: If you use the standard sequence generator in hibernate, it is >> not using the postgres-sequence in the "usual" manner. hibernate itself >> caches 50 ID's as sequence numbers by default. This means, hibernate >> only does a select on the database sequence every 50 numbers. it >> multyplies the database sequence by 50 to get the "real" sequence >> number. it generates the sequence numbers in blocks of 50 numbers or >> according to the sequence cache size. >> That said, you would probably not see any performance bottlenecks >> because of the sequence number generator in the database, even with >> thousands of inserts per second. >> >> > > Hi Leo, thank you for the explanation! > > I don't know if it is that cool to lose up to 50 IDs on each session-end of > Hibernate... > And what do you suppose it would happen, if I set the cache size of > Hibernate's own sequence (after generation) by hand to 1 instead of 50? I > wouldn't need tausends of inserts per second... > > Kind regards, Rawi > >