Type question for internal id and its dimension

rdiana

Member
Dear Rob and Hugh,
I've a question about the primary key for each table.
When I create a list/table, the field id (internal id) is created but no "advanced" option about its type is present (for example: smallint, int...). I think it would be very useful to avoid not necessary bytes in short tables or, on the contrary, use enough bytes in long tables (a user list, for example).
On the other hand, I've noticed (by using phpmyadmin) in some tables the id field is 6 bits long, in other is 11 bits long. The dimension is dinamically changed?

Cheers,

Roberto
 
The 6 and 11 "size" you are referring to doesn't actually affect the numeric size of the field, it's simply the "display width" which is available to applications, so they can optionally present the data with padding. As per the MySQL documentation:

For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.)

The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly.

So UNSIGNED INT(6) and UNSIGNED INT(11) are no different in that they can both handle integers up to 4,294,967,295. If you need more than 4.2 billion records, then you probably don't need to be using Fabrik. ;)

And if you really, really need to save 2 bytes per row by using a SMALL or TINY int, then you can simply set "Alter existing fields" on your list settings to "No", then go in to phpMyAdmin and change your PK type. But I really can't imagine any situation where saving 2 bytes per row is going to help. Even if you have a million rows, that's only 2MB of space ... which in today's storage terms is negligible.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top