What are the most efficient MySQL column types for this data?

I have several tables with some pretty standard data in each. Can someone help me optimize them by showing me the best column types for this data. That they have what I have now.

Number (max length 7) --> MEDIUMINT(8) Unsigned
Text (max length 30) --> VARCHAR(30)
Text (max length 200) --> VARCHAR(200)
Email Address (max length 200) --> VARCHAR(200)
Number (max length 4) --> SMALLINT(5) Unsigned
Number (either 0 or 1) --> TINYINT(1) Unsigned
Text (max length 500) --> TEXT

Any suggestions? I just guess it, so I know some of them are wrong ...

+3
source share
4 answers

Sorry this is not a direct answer to your question, but I think this should be indicated. I think you may have misunderstood the purpose of the whole in brackets after the column type.

VARCHAR, , , , . , . 5 -, , VARCHAR(100) VARCHAR(200).

. , - . . :

MySQL , (, INT (4)). , , , , . ( , . .)

, , , , , .

+1
Number (either 0 or 1) --> TINYINT(1) Unsigned

.

0

.

Please note: you cannot optimize anything with column types. Using indexes you do.

0
source

Depends on your definition of effective. For speed, CHAR can be faster than VARCHAR (since each line ends in the same length, making it easier to find a given record). But all your fields should have a fixed length or not bother.

0
source

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


All Articles