MySQL performs a full table scan under the following conditions:
1> the data table is too small, and a full table scan is much faster than the search for the index key. This is usually done when the total number of records in a table is less than 10 and the record length is relatively short.
2> there is no index field suitable for on or where clause.
3> compare index fields with constant values. MySQL has computed (based on the Index Tree) to cover a large part of the data table. Therefore, full table scanning should be faster.
4> Other Fields use an index key with a small base (many records match the index key value. In this case, MySQL considers that using index keys requires a large number of searches, which is not as fast as full table scan.
For small tables, full table scan is usually more appropriate. However, for large tables, try the following technologies to avoid optimization: ProgramIncorrectly select full table scan:
1> execute analyze table tbl_name to update the index key distribution of the table to be scanned.
2> Using Force Index tells MySQL that full table scan will waste more resources than using the given index.
Select * from T1, T2 Force Index (index_for_column)
Where t1.col _ name = t2.col _ name;
3> when starting mysqld, use the -- Max-seeks-for-Key = 1000 parameter or run set max_seeks_for_key = 1000 to notify the optimization program, all indexes do not cause more than 1000 index searches.
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