MySQL and Index

Source: Internet
Author: User

The larger the data size, the greater the difference between indexes. In fact, small personal professional applications can achieve the desired speed without indexing. When there are about 1000 data records, the additional overhead of tree search is greater, and searching from the beginning is faster normally. However, when the data grows, there will be a situation where no index is available. Therefore, the index is very important. In addition, there is a certain degree of internal optimization in MySQL. It will determine whether to use indexes quickly or not based on the number of records.

However, MySQL is also insufficient, and the applicability of MySQL is a little poor. Even if you query an indexed column, some SQL statements do not use the index.

  • Basically, the following indexes are used:

The column specified in the where, order by, and group by conditions.

For example, if the select * from entry where url = "http: //..." query specifies the URL column in The where statement, it will be used if the URL column has an index.

  • When the index is valid

    -> Explicitly added Indexes

    -> Primary key and unique constraints

    In MySQL, apart from explicitly adding indexes using the alter table command, columns with primary keys and unique constraints have indexes. Use the show Index Command to confirm the index content.

  • MySQL index traps

    -> To use the index of multiple columns at the same time, you must use a composite index.

There is a problem here. MySQL can only use one index for each query. If you want to use two indexes at the same time, you must set the index (URL, timestamp.

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.