performance penalty of strings as primary keys?

前端 未结 4 1714
旧巷少年郎
旧巷少年郎 2020-12-30 06:42

What would be the performance penalty of using strings as primary keys instead of bigints etc.? String comparison is much more expensive than integer comparison, but on the

4条回答
  •  悲哀的现实
    2020-12-30 07:21

    It depends on several factors: RDBMS, number of indexes involving those columns but in general it will be more efficient using ints, folowed by bigints.

    Any performance gains depend on usage, so without concrete examples of table schema and query workload it is hard to say.

    Unless it makes sense in the domain (I'm thinking unique something like social security number), a surrogate integer key is a good choice; referring objects do not need to have their FK reference updated when the referenced object changes.

提交回复
热议问题