<p>Identifier generator optimization<br>For identifier generators which store values in the database, it is inefficient for<br>them to hit the database on each and every call to generate a new identifier<br>value. Instead, you'd ideally want to group a bunch of them in memory and<br>only hit the database when you have exhausted your in-memory value group.<br>This is the role of the pluggable optimizers. Currently only the two enhanced<br>generators (Section 5.1.5, “Enhanced identifier generators” support this<br>notion.<br>• none (generally this is the default if no optimizer was specified): This says<br>to not perform any optimizations, and hit the database each and every<br>request.<br>• hilo: applies a hi/lo algorithm around the database retrieved values. The<br>values from the database for this optimizer are expected to be sequential.<br>The values retrieved from the database structure for this optimizer<br>indicates the "group number"; the increment_size is multiplied by that value<br>in memory to define a group "hi value".<br>• pooled: like was discussed for hilo, this optimizers attempts to minimize<br>the number of hits to the database. Here, however, we simply store the<br>starting value for the "next group" into the database structure rather than<br>a sequential value in combination with an in-memory grouping algorithm.<br>increment_size here refers to the values coming from the database.</p>
<p>对于主键生成器的优化的主要策略是不要每次需要主键的时候都去访问一次数据库。hilo和pooled可以实现。</p>
<p>上文中所说的两种“only the two enhanced generators”是指在hibernate3.3.2中新引入的两个价钱的主键生成策略org.hibernate.id.enhanced.SequenceStyleGenerator和org.hibernate.id.enhanced.TableGenerator</p>
<p>对于主键生成器的优化的主要策略是不要每次需要主键的时候都去访问一次数据库。hilo和pooled可以实现。</p>
<p>上文中所说的两种“only the two enhanced generators”是指在hibernate3.3.2中新引入的两个价钱的主键生成策略org.hibernate.id.enhanced.SequenceStyleGenerator和org.hibernate.id.enhanced.TableGenerator</p>