3 ms·
> 2) a non integer primary key is slow Is this actually true in Postgres? Unless things have changed Postgres doesn't keep clustered indexes so index fragmenta
by ForHackernews 6y ago
> 2) a non integer primary key is slow
Is this actually true in Postgres? Unless things have changed Postgres doesn't keep clustered indexes so index fragmentation is not an issue.
- opmac 6y agoIt is somewhat slower if you are looking up records by key. You still need an index to do that, and non-integer PKs such as UUIDs can be twice as large as the integer alternative, taking longer to search while requiring more memory. That being said, in PostgreSQL, you are correct --- having a UUID (or something similar) as a PK is usually fine assuming you understand the implications. However I would absolutely avoid it in a DB like MySQL where PKs are clustered.