MySQL database simple query performance analysis

Source: Internet
Author: User

  Create a data table with such a structure and insert 1.1 million random records to test the query performance.

After 1.1 million random records are inserted, the data table size is 102 MB.

Now we use the SQL queryer that comes with phpMyAdmin For performance analysis.

  The following is a query test in the indexed mode:

A. Random round-match query of all fields, in 0.0005 (S)

B. Random primary key query in 0.0005 (S)

C. Random query using character functions, with a time of 0.4482 (S)

D. Use the LIKE mode for a query. The query time is 0.0007 (S)

E. Use LIKE Mode 2 for query. The query time is 0.7361 (S)

  The following example shows how to perform a test when an index is deleted:

A. Random round-match query of all fields, in 0.3439 (S)

B. Random primary key query in 0.0004 (S)

C. Random query using character functions, with a time of 0.4882 (S)

D. Use the LIKE mode for a query. The query time is 0.3487 (S)

E. Use LIKE Mode 2 for query. The query time is 0.7339 (S)

  Conclusion:

  When you perform a simple query on a field, if the field is indexed, the query speed is much faster than if no index is created. Use MySQLThe function query speed is similar to that without an index even when an index is created. When using LIKEXxx %In the mode, the index is far faster than the index is not, but % xxx %The mode is the same if there is an index or no index.

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.