What's your opinion on using UUIDs as database row identifiers, particularly in web apps?

后端 未结 15 2186
深忆病人
深忆病人 2020-12-12 12:43

I\'ve always preferred to use long integers as primary keys in databases, for simplicity and (assumed) speed. But when using a REST or Rails-like URL scheme for object insta

15条回答
  •  一个人的身影
    2020-12-12 13:41

    I don't think a GUID gives you many benefits. Users hate long, incomprehensible URLs.

    Create a shorter ID that you can map to the URL, or enforce a unique user name convention (http://example.com/user/brianly). The guys at 37Signals would probably mock you for worrying about something like this when it comes to a web app.

    Incidentally you can force your database to start creating integer IDs from a base value.

提交回复
热议问题