Which part of a GUID is most worth keeping?

前端 未结 5 863
情话喂你
情话喂你 2020-12-15 23:06

I need to generate a unique ID and was considering Guid.NewGuid to do this, which generates something of the form:

0fe66778-c4a8-4f93-9bda-36622         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 00:00

    I agree with Rob - Keep all of it.

    But since you said you're going into a database, I thought I'd point out that just using Guid's doesn't necessarily mean that it will index well in a database. For that reason, the NHibernate developers created a Guid.Comb algorithm that's more DB friendly.

    See NHibernate POID Generators revealed and documentation on the Guid Algorithms for more information.

    NOTE: Guid.Comb is designed to improve performance on MsSQL

提交回复
热议问题