Scenario: Hi/Lo is initialized for MyEntity
with Lo 100
The table is empty.
Two sessions with different connections have both inserted three items.
TableIds
1
2
3
100
101
102
If a third one comes in at a later time and inserts three items:
TableIds
...
200
201
202
Is there a way to not get these gaps?
As
Phill
quite rightly pointed out the gaps appear when you build asessionFactory
e.g. the application restarts etc or you are running on the cloud and each node has its own set ofHi
andlo
.You could reduce the lo to
10
rather than100
to reduce the gaps and/or I recommend usingint64
rather thanint32
for ease of mind.However does the gaps actually matter? Would you ever see yourself running out?
I have never read anything negative about performance (database issues) with a large number of gaps when using
Hilo
. The only thing I have seen is that some people complain that they run out when usingint32
or when thelo
has been set to high.