Giter VIP home page Giter VIP logo

Comments (4)

holly-hacker avatar holly-hacker commented on September 17, 2024 1

It's worth mentioning that UUIDs also bring security benefits. An online store may leak information about their sales numbers if they expose integer IDs for their order numbers, allowing competitors to monitor their activity. Malicious actors may also use them to enumerate/scrape resources which may not be desirable. I'd personally recommend UUIDs over integers unless you expect to never expose these ids or have a good reason to use them.

from http-api-design.

brandur avatar brandur commented on September 17, 2024

It may indeed be worthwhile to amend this one slightly, even if only to make it clear that it's certainly not a slam dunk to use UUIDs.

The way I see it, UUID advantages:

  • Operational errors, even across different tables/resources, are incredibly difficult to do by accident. Two different resources in two different tables might share the ID 23, but when it comes to UUIDs, no entity shares an ID with anything else in the database. This has legitimately saved me a couple times as I've run an UPDATE against the wrong table (again, accidentally).
  • Scales well beyond a single master database.

Sequence/serial advantages:

  • Much improved data locality in that new data will land in the same nodes in the B-tree/pages on disk. If you have a table with a lot of INSERTs happening, sequences will be far more performant I/O-wise.
  • More human friendly in that it's easy to copy or remember a comparatively short integer ID compared to a UUID.

from http-api-design.

geemus avatar geemus commented on September 17, 2024

Good callouts. Do you think we should move from a recommendation to an explanation of the tradeoffs then?

from http-api-design.

geemus avatar geemus commented on September 17, 2024

I'd welcome a PR if you'd like to draft some updates.

from http-api-design.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.