Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good MaxLo value for the HiLo algorithm?

In my current design, I have HiLo setup to have a MaxLo of 1000. Is this being excessive? Could I reduce this number to something like 100 and still be ok?

public class HiLoConvention : IIdConvention
{
    public void Apply(IIdentityInstance instance)
    {
         instance.GeneratedBy.HiLo("1000");
    }
}
like image 456
rebelliard Avatar asked May 09 '11 14:05

rebelliard


1 Answers

The HiLo value controls how "fast" you'll burn through the range of the numeric type you've selected for the Id. Anytime a new NHibernate configuration is loaded, the HiLo range of new Ids is initialized and it is discarded when the application is disposed. If your application has low activity and you want a "slow" burn rate pick something like 10 because your more likely to consume all Ids for a given application load/dispose cycle.

Remember, if NHibernate runs out of Ids, it just fetches another set. If your application gets slammed pretty regularly, then setting it at 1,000 may make more sense to reduce database calls. It a trial & error thing.

like image 96
Sixto Saez Avatar answered Sep 20 '22 06:09

Sixto Saez