Before performing a table scan, the info () function is called to provide additional information for the optimizer.
The information required by the optimizer is not specified by the return value. You need to fill in the specific attributes of the storage engine class. When info () is returned, the optimizer reads the storage engine class.
In addition to being used by the optimizer, many value sets are also used in the show table status statement when the info () function is called.
The complete public attributes are listed in SQL/handler. h. Below are some common attributes:
Ulonglong data_file_length;
/* Length off data file */
Ulonglong max_data_file_length;
/* Length off data file */
Ulonglong index_file_length;
Ulonglong max_index_file_length;
Ulonglong delete_length;
/* Free bytes */
Ulonglong auto_increment_value;
Ha_rows records;
/* Records in table */
Ha_rows deleted;
/* Deleted records */
Ulong raid_chunksize;
Ulong mean_rec_length;
/* Physical reclength */
Time_t create_time;
/* When table was created */
Time_t check_time;
Time_t update_time;
For Table scanning, the most important attribute is "records", which specifies the number of records in the table. When the storage engine specifies that there are 0 or 1 rows in the table, or there are more than 2 rows, the execution method of the optimizer is different in both cases. Therefore, when you do not know the number of rows in the table before performing a table scan, you should return a value greater than or equal to 2. This is very important (for example, data is filled externally ).