If it is very compressed and omitting numerous details, then according to MySQL you move with the help of address arithmetic, i.e. you can always very quickly figure out in which memory area this or that entry is located. This is achieved as follows.
All data of fixed length like INT
, FLOAT
are placed directly in the record structure. Plus, there is a dynamic section in the record, which is 65536 bytes in length in which data of non-fixed length are placed like VARCHAR
, and NULL values are stored here. If you create several VARCHAR
columns that completely select this dynamic part of 65536 bytes, MySQL will not allow you to create new columns (Try creating UTF-8 VARCHAR of 65536 length for the sake of interest - either 3 or 4 bytes are allocated for UTF8-symbol in MySQL depending on the encoding). Heavy artillery like BLOB
, TEXT
fields are generally kept separate. Therefore, you can always calculate the address of your record, just map the data into memory, you know where the beginning of the section of memory, and the address of any line you can calculate if you know the size of a fixed section. It also stores the address of the dynamic section and BLOB/TEXT
values.
There is an excellent book "MySQL. Performance Optimization. Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zoodnay, Derek J. Balling, Arjen Lenz". Translated into Russian and is an excellent introduction to the architecture of MySQL.
fseek
function (depending on your language / platform). And as a result (simplified) the head of the hard disk quickly moves to the desired sector. - Vladimir Gamalyanseek
access to the operating system, that to the driver of the disk, and he knows how quickly to move the head to the desired piece by displacement (exaggerated, but the essence is approximately like this) - Vladimir Gamalyan