Invalid MYSQL indexes and valid indexes _ MySQL-mysql tutorial
Source: Internet
Author: User
Invalid MYSQL index and effective index details bitsCN. com1, WHERE clause query conditions have not equal to (WHERE column! =...), MYSQL will not be able to use the index
2. Similarly, if the WHERE clause uses a function (for example, where day (column) =...) in the query condition, MYSQL will not be able to use an index.
3. in the JOIN operation (when data needs to be extracted from multiple data tables), MYSQL can use indexes only when the primary key and foreign key data types are the same. otherwise, even if
The index will not be used either.
4. if the comparison operators LIKE and REGEXP are used in the query conditions of the WHERE clause, MYSQL can only search for templates if the first character of the template is not a wildcard character.
Use indexes. For example, if the query condition is LIKE 'ABC % ', MYSQL uses an index. if the condition is LIKE' % ABC', MYSQL does not use an index.
5. in the order by Operation, MYSQL uses indexes only when the sorting condition is not a query condition expression. However, the query involves multiple data tables.
In the query, even if indexes are available, those indexes do not play a role in accelerating the order by operation.
6. if a data column contains many duplicate values, creating an index for it will not be very effective. For example, if a data column contains
Such as "0/1" or "Y/N", there is no need to create an index for it.
7. too many indexes are useful. Basically, as long as an index is created, except that the index mentioned above is not used
In the WHERE condition, the order by field and the joined table field are generally valid. Creating an index requires results. Otherwise, why? If not
Whether the index created on a field is effective, as long as the actual test is performed to compare the execution time. BitsCN.com
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