Re: Hibernate, web application and only one sequence for all primary keys

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: rawi <only4com(at)web(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Hibernate, web application and only one sequence for all primary keys
Date: 2009-09-17 15:05:51
Message-ID: 4AB2504F.1010405@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Leo Mannhart 2009-09-17 15:07:21 Re: Hibernate, web application and only one sequence for all primary keys
Previous Message rawi 2009-09-17 14:55:16 Re: Hibernate, web application and only one sequence for all primary keys