logoalt Hacker News

dspillett • yesterday at 8:58 PM • 1 reply • view on HN

> If you need to list things ordered by creation time very often, it’s useful if the primary index gives that behavior, removing the need for another index.

If you are using your primary key for anything other than a unique identifier for rows, you are almost certainly doing something wrong. If you need an index on creation time, or just creation order, have a creation time column and an index on that.


Replies

sbuttgereit • today at 1:05 AM

Hear, hear. Just because something -looks- like it has the qualities of a sequence, order, or other meaning outside of that one thing which it is: an identity, doesn't mean that you can reliably use it for that other purpose. I don't care if it's a UUIDv7 or am autoincremented-integer-of-some-sort: you're getting a record ID and nothing more. Mistaking and ID for something more is the best preparation for some poor soul's headache at some point in the (possibly distant) future.

➕ show 1 reply