What's the Hi/Lo algorithm?

前端 未结 5 1799
面向向阳花
面向向阳花 2020-11-22 06:00

What\'s the Hi/Lo algorithm?

I\'ve found this in the NHibernate documentation (it\'s one method to generate unique keys, section 5.1.4.2), but I haven\'t found a goo

5条回答
  •  情歌与酒
    2020-11-22 06:33

    I found the Hi/Lo algorithm is perfect for multiple databases with replication scenarios based in my experience. Imagine this. you have a server in New York (alias 01) and another server in Los Angeles (alias 02) then you have a PERSON table... so in New York when a person is create... you always use 01 as the HI value and the LO value is the next secuential. por example.

    • 010000010 Jason
    • 010000011 David
    • 010000012 Theo

    in Los Angeles you always use the HI 02. for example:

    • 020000045 Rupert
    • 020000046 Oswald
    • 020000047 Mario

    So, when you use the database replication (no matter what brand) all the primary keys and data combine easily and naturally without to worry about duplicate primary keys, collissions, etc.

    This is the best way to go in this scenario.

提交回复
热议问题