Mysql: 21 performance optimization best practices 4 [index search fields] _ MySQL

Source: Internet
Author: User
Mysql: 21 best practices for performance optimization 4 [index search fields] Mysql: 21 performance optimization best practices 4 [index search fields] _ MySQL

Create an index for a search field

An index is not necessarily a primary key or a unique field. If a field in your table is always used for search, create an index for it.


You can see the search string "last_name LIKE 'a % '". one is an index, the other is no index, and the performance is about 4 times worse.
In addition, you should also know what kind of search cannot use normal indexes. For example, if you need to search for a word in a large article, for example, "WHERE post_content LIKE '% apple %'", the index may be meaningless. You may need to use MySQL full-text indexes or make an index yourself (for example, search for keywords or tags ).

The above is mysql: 21 best practices for performance optimization 4 [create an index for a search field] _ MySQL content. For more information, see The PHP Chinese network (www.php1.cn )!

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.