Should text columns be moved to the end?

Is there a difference between the speed of receiving data if dynamic lines are moved to the end.

example: int, int, int, text is better than int int text int?

my leadership informed me of this fact, how has such information ever come from the Internet? please, help?

+6
source share
2 answers

This is due to data alignment. INT occupies 4 bytes, so 32-bit (equivalent to 4 bytes) processors will work with data in 4 byte sequences. The ability to retrieve data in the order that best suits the processor will result in faster results and better performance.

Link : http://en.wikipedia.org/wiki/Data_structure_alignment

Now this is a problem often encountered when transmitting data over a communication channel (since some compilers usually optimize your data structure by adding a reserved byte of 4 bytes to align certain elements). However, MySQL also allows for 4-byte alignment using NDBCLUSTER . This means that by placing the TEXT structure between INT values, you are forcibly increasing the data search than necessary.

Thus:

INT INT INT INT TEXT will process faster than INT INT TEXT INT INT , since the processor can extract 16-byte (four INT ) without worrying about the size of the TEXT .

See the MySQL documentation for more details:

http://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html

+3
source

TEXT and BLOB data are not stored in the same space as the column itself. They are stored in a special area reserved for this purpose.

These columns are always slower to retrieve, but the number of slowdowns varies greatly depending on your system setup and data loading. Sometimes it does not matter, and sometimes it leads to serious fraud. Just keep in mind that you should use the short VARCHAR field in the TEXT field if you can control it that the longer blob fields do not come for free.

At the same time, TEXT columns are stored in the row as a pointer to the actual data, which makes them much smaller than VARCHAR in most cases. If you do not select them, they will not load, and you will not require additional searches necessary to collect your data.

To be sure this applies to your version of MySQL and your setup, build two large tables full of representative data and compare them yourself.

+1
source

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


All Articles