More than char, but less than blob

Chars are great because they are fixed in size and therefore make for a faster table. However, they are limited to 255 characters. I want to contain 500 characters, but blob is a variable length, and that is not what I want.

Is there a way to have a field with a fixed length of 500 characters in MySQL or will I have to use 2 char fields?

+3
source share
3 answers

I would suggest using varchar (500). Although varchar is not a fixed length, the database must reserve the correct space. You should not notice a difference in performance with varchar (500) compared to 2xchar (255).

, , , char.

+6

varchar (500)

... MySQL 5.0.3 . VARCHAR 255 .

, CHAR VARCHAR . 10.4.1. CHAR VARCHAR ( MySQL 5.0).

+2

You are too worried about the details of the internal implementation. Do not pre-optimize.

Go with VARCHAR(500)

0
source

Source: https://habr.com/ru/post/1696381/


All Articles