Id vs gid in applications

What’s the reason for both an id and a gid? If I have something that’s using the id, is that in danger of being changed at some point? If only gids are dependable, why are there ids at all? Just for joining? Why not use the gid for joining, in that case?

Just speculating, but one downside to using UUIDs in foreign key columns is that it would bloat the size of various tables – instead of a 4-byte SERIAL value, at least 16 bytes would be needed (or more, depending on the representation). Presumably there would be performance implications from using longer keys for joins, too.

2 Likes

I would say it’s probably because Strings Primary Keys are bad performance in general

There’s also the fact that GIDs “change” over time. If you merge an entity, there’s one GID that is now the alias of another, making it seems like there’s a separate entry when there isn’t.

1 Like