List:Internals« Previous MessageNext Message »
From:Hagen Höpfner Date:December 14 2005 10:13pm
Subject:MYI ... Basedata ...
View as plain text  
Dear List,

i am back from a business trip, where I had a lot of time to try to
understand the remainer of the MYI-Structure. Unfortunately, the
internals documentation and the comments in the source code raise more
question than they answer ;-( However, let me again try to describe,
what I believe and say yes if I am right in point or correct my answer,
please ... The structure was taken from mi_open.c:
------------------------------------------------------------
 mi_sizestore(ptr,base->keystart);            ptr +=8;
I assume that this stores again the start of the key values of the first
key ...
------------------------------------------------------------
  mi_sizestore(ptr,base->max_data_file_length);        ptr +=8;
  mi_sizestore(ptr,base->max_key_file_length);        ptr +=8;
Both values are corrected in mi_open.c but why are they stored in the
MYI-file if they are corrected with each open?
I assume, that they describe the maximal possible length of the MYD file
or the MYI file respectively. But why and when it is really necessary to
correct them.
------------------------------------------------------------
  mi_rowstore(ptr,base->records);            ptr +=8;
  mi_rowstore(ptr,base->reloc);                ptr +=8;
I have got no idea what this values encode/mean?
------------------------------------------------------------
  mi_int4store(ptr,base->mean_row_length);        ptr +=4;
I believe that the name says what the meaning is, but I was not able to
find any function that uses this value and in my tests the value stayed
00 00 00 00 ... so is it really in use?
------------------------------------------------------------
  mi_int4store(ptr,base->reclength);            ptr +=4;
This seams to be the lenght of noncompressed/unpacked records (described
in myisamdef.h) but how is it computed? In the internals doc I found the
information, that reclength is the sum of the lengths of all attributes
of the relation. But the example focuses on fixed length columns only. I
tried to calculate reclength for a table with an int, a varchar(100) and
a text attribute. The reclength in the MYI-file is 116 (0x00 00 00 74)
... is 116 the sum of 4 (int) and the maximal "real" lengths of the both
other attributs?
------------------------------------------------------------
  mi_int4store(ptr,base->pack_reclength);        ptr +=4;
Is this the average for a packed record? If so, how is it computed? If I
do not pack the data file, then pack_reclength is equal to reclength,
isn't it?
In mi_static.c i found the following:
    if (info->state->data_file_length > info->s->base.max_data_file_length-
    info->s->base.pack_reclength)
    ... means data file is full
Does this mean, that I got the error, if it would not be possible to
store a new packed record?
------------------------------------------------------------
  mi_int4store(ptr,base->min_pack_length);        ptr +=4;
  mi_int4store(ptr,base->max_pack_length);        ptr +=4;
This are the minimal and the maximal possible legth of packed records,
aren't they?
------------------------------------------------------------
  mi_int4store(ptr,base->min_block_length);        ptr +=4;
Minimal block length of what? Of an index page?
------------------------------------------------------------
  mi_int4store(ptr,base->fields);            ptr +=4;
Number of attributes +1 (so it is described in the internals doc). But
why do you need the +1?
------------------------------------------------------------
  mi_int4store(ptr,base->pack_fields);            ptr +=4;
What does this mean. In my example, described above, this value is 1 but
I do not have a packed field?
------------------------------------------------------------
  *ptr++=base->rec_reflength;
  *ptr++=base->key_reflength;
I assume this is the length of the pointers either refering another
key-entry or a record in the data-file. Both values are 4 in my example.
------------------------------------------------------------
  *ptr++=base->keys;
The number of keys.
------------------------------------------------------------
  *ptr++=base->auto_key;
Which key is indexes the auto increment attribute. Zero if no auto
increment attribute.
------------------------------------------------------------
  mi_int2store(ptr,base->pack_bits);            ptr +=2;
I have no idea ;-)
------------------------------------------------------------
  mi_int2store(ptr,base->blobs);            ptr +=2;
Number of blobs. But why it is 1 in my example. I do not have a blob or
a text attribute going to be interpreted as a blob?
------------------------------------------------------------
  mi_int2store(ptr,base->max_key_block_length);        ptr +=2;
maximal allowed size of a key page ... predifined 1024 ... but in
myisam.h MI_MAX_KEY_BLOCK_LENGTH is defined as 16384. What is the
difference between MI_... and max_key_...?
------------------------------------------------------------
  mi_int2store(ptr,base->max_key_length);        ptr +=2;
Maximal allowed length of a key value (includes the pointer) ... In my
example (with a fulltext index) the value is 272 (0x0110). Where and how
is is calculated?
------------------------------------------------------------
  mi_int2store(ptr,base->extra_alloc_bytes);        ptr +=2;
  *ptr++= base->extra_alloc_procent;
I do not have any idea ;-)
------------------------------------------------------------
  *ptr++= base->raid_type;
A flag that indicates the used RAID type ... It was specified during
CREATE TABLE ... From the mysql doc i learned, that i have three
options:{ 1 | STRIPED | RAID0 }. Unfortunately I was not able how these
three (or two, I typically mix up RAID 0 and RAID 1 but one mens
STRIPED, so what is the difference here)  types are encoded and
represented in this one byte in the MYI file.
------------------------------------------------------------
  mi_int2store(ptr,base->raid_chunks);            ptr +=2;
  mi_int4store(ptr,base->raid_chunksize);        ptr +=4;
Both values come from the create table statement?
------------------------------------------------------------
  bzero(ptr,6);                        ptr +=6; /* extra */
Hm, I have absolutely no idea, why you researved 6 extra bytes, here ...
Are they used anyhow?
------------------------------------------------------------

Again, questions over questions, but I seriously thry to understand the
MyISAM internals ;-)

Hagen

Thread
MYI ... Basedata ...Hagen Höpfner19 Dec
  • Re: MYI ... Basedata ...Sergei Golubchik19 Dec
    • Re: MYI ... Basedata ...Hagen Höpfner3 Feb
      • Re: MYI ... Basedata ...Sergei Golubchik7 Feb
    • Re: MYI ... Basedata ...Hagen Höpfner20 Feb
      • Re: MYI ... Basedata ...Sergei Golubchik20 Feb
        • Packed Data in MyISAMHagen Höpfner23 Feb
          • Re: Packed Data in MyISAMSergei Golubchik23 Feb
            • Re: Packed Data in MyISAMHagen Höpfner23 Feb
              • Re: Packed Data in MyISAMSergei Golubchik24 Feb