Testing of improper indexing in MySQL is slower than without an index

Source: Internet
Author: User

The following figure shows the data inserted into the tuangou table:

Id web city type
1. Beijing Food & Beverage
2. Shanghai leisure and entertainment
3% group Tianjin Food & Beverage
4. Online Shopping in Shenzhen
Discount coupons for Shijiazhuang
6% group Handan beauty and health care
..
Chongqing Travel Hotel 4999
5000 discount coupons in Xi'an

Run the MySQL statement:
$ SQL = "select from tuangou where web = 'handler' and city = 'shanghai '";

(1) If no index is added, the execution time is: 0.0041 seconds.

(2) If you only add an index to the Web, the execution time is 0.0064 seconds.

(3) If both the web and city are indexed, the execution time is 0.0007 seconds.

Although the index is added in (2), the query time is longer than the time when no limit is referenced. Therefore, I suggest you add indexes to fields frequently queried.

Related Article

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.