How to use index to optimize MySQL properly

Source: Internet
Author: User
Tags mysql

In MySQL, because the use of limit this syntax, for paging query is very convenient, but also brought in the ranking of performance bottlenecks, reasonable use of the index, can greatly improve the running speed of MySQL.

Indexes are generally applied to fields used for cross table joins and sorting, and in practical applications, we tend to apply to the possibility of ordering multiple fields, and the following points need to be noted:

1, the primary key field does not need to re-establish the index

2, for the use of multiple fields by the sort of possible situation, to establish an index do not put the index in the same group, such as
Select * from xxx_table where xxx=1 order BY click Desc
Select * from xxx_table where xxx=1 order by postdate Desc
When this happens, you have to create a set of indexes for each click and postdate, otherwise the index has too many fields attached to it, and the index of the system is basically useless.

3, the frequently queried fields can be indexed.

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.