Home  >  Q&A  >  body text

Should the length of varchar type in MySQL be a multiple of the field's encoding?

I once saw someone on stackoverflow saying that it is recommended that when the length of the varchar field cannot be estimated, it is best to set it to an integer multiple of the encoding. For example, if the utf8 encoding is three bytes, then setting it to 255 is more appropriate. Is there any scientific basis for this?

習慣沉默習慣沉默2710 days ago589

reply all(3)I'll reply

  • 滿天的星座

    滿天的星座2017-05-18 10:51:34

    I only know that the maximum length of varchar is 255

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-18 10:51:34

    Prevent space waste and fragmentation

    reply
    0
  • 某草草

    某草草2017-05-18 10:51:34

    I think this is more appropriate.

    reply
    0
  • Cancelreply