varchar , text difference

ash3767·2021년 7월 20일


목록 보기

📌reference site

i want to settings fk between parent table and child table By the way you know that it's usually use integer type

and we can FK to varchar type but can't use text type

📌varchar , text difference

👉 varchar

  • the varchar can be used as part of index.
  • the varchar is stored in memory and fast more than text
  • varchar: x <= 255 then, 1 byte, 256 <= x <= 65535 then, 2 byte

👉 text

  • text can not be used as part of index.
  • the text is stored in disk and slow more than varchar
  • Unconditionally 2 byte

so text is stored on disk , and if you called query frequently , it's has a big performance difference , so you should be careful about using it

so we can set varchar to FK.

Backend Development

0개의 댓글