4 ms·
Stop Using Serial in Postgres
- pauldraper 2y agoOne advantage to using sequences (not serial, but close) is that you can drive all IDs from one sequence, helping to prevent mistakes of ID misuse.
- foobarkey 2y agoNo and this is all well known stuff, none of it seems like a good reason to stop using
- microflash 2y agoYeah, that's why the post is an opinion piece. I got bitten by the permissions issue and wanted to write this for my peers at work. As long as you're aware of tradeoffs, it is fine to use it. Personally, I have grown to like the identity columns since I work across different database vendors.
- linotype 2y agoIt would be nice to have a link to the PG docs for identity columns in addition to the Wikipedia article about them.
- linotype 2y agoIdentity columns in Postgres: https://www.postgresql.org/docs/17/ddl-identity-columns.html https://www.postgresql.org/docs/17/ddl-identity-columns.html