Using “varchar” as the primary key? bad idea? or ok?

前端 未结 5 2007
一整个雨季
一整个雨季 2021-01-01 12:43

Is it really that bad to use \"varchar\" as the primary key?

(will be storing user documents, and yes it can exceed 2+ billion documents)

5条回答
  •  时光说笑
    2021-01-01 13:17

    I think int or bigint is often better.

    1. int can be compared with less CPU instructions (join querys...)
    2. int sequence is ordered by default -> balanced index tree -> no reorganisation if you use an PK as clustered index
    3. index need potentially less space

提交回复
热议问题