ограничения для int

Slastik

Новичок
ограничения для int

запись типа int(9) дает мне что либо кроме того что я не могу хранить число более 999 999 999 ?
то есть вплане производительности это что то дает? ведь все равно выделяется 4 байта
 

Фанат

oncle terrible
Команда форума
хранить можешь и больше
ничего не дает
формат чисел ВООБЩЕ никакого отношения к производительности не имеет
 

Slastik

Новичок
я может не правильно выразился
речь идет о типе поля для таблицы

допустим объявления поля smallint или int даст разницу в производительности так как выделяется уже меньше байт
 

berkut

Новичок
даёт преимущество. как можно меньше нужно и соответствующего типа
 

Slastik

Новичок
berkut

то есть лучше писать int(9) вместо int(11)?
можете аргументировать?
 

berkut

Новичок
раздел мана по мусе 7.4.2. Make Your Data as Small as Possible

-~{}~ 05.05.08 23:35:

[q]You can get better performance for a table and minimize storage space by using the techniques listed here:

Use the most efficient (smallest) data types possible. MySQL has many specialized types that save disk space and memory. For example, use the smaller integer types if possible to get smaller tables. MEDIUMINT is often a better choice than INT because a MEDIUMINT column uses 25% less space.
[/q]
 

Mr_Max

Первый класс. Зимние каникулы ^_^
Команда форума
Slastik
У тебя есть реальный шанс найти/не найти аргументы самостоятельно протестировав запросы.
 

Slastik

Новичок
хотя даже в контексте места, оптимизация не такая уж сильная
на 1 000 000 записей это 1мб
 

Андрейка

Senior pomidor developer
а цифирка в скобочках после целочисленного типа данных вроде как имеет весьма далекое отношение к производительности и месту на диске
 

melo

однажды
Another extension is supported by MySQL for optionally specifying the display width of integer data types in parentheses following the base keyword for the type (for example, INT(4)). This optional display width is used to display integer values having a width less than the width specified for the column by left-padding them with spaces.
The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters.
When used in conjunction with the optional extension attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004. Note that if you store larger values than the display width in an integer column, you may experience problems when MySQL generates temporary tables for some complicated joins, because in these cases MySQL assumes that the data fits into the original column width.
 
Сверху