How to Implement the info () function in MySQL

Source: Internet
Author: User

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 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.