centos7-mysql-Index Optimization

Source: Internet
Author: User

index optimization to optimize query speed
-------------------------------------------------------
count, statistics a table Total row count
The MyISAM storage engine has its own counter, and it is fast to extract counter values directly using Count
InnoDB requires full table sweep face when using count, each row is inefficient
--------------------------------------------------------
Binary multimedia data, do not exist in the database
Large text data, and do not exist in the database
Different SQL statements can also affect execution efficiency
--------------------------------------------------------
Index
Explain simulation statement query status, providing data "commands used frequently"
650) this.width=650; "height=" 346 "src=" http://b246.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ ysln9xenhrkj41wmpagyu5ataipjmowzodzan22h6oi!/b/dpyaaaaaaaaa&bo=pwjaaqaaaaafefu! "width=" 575 "style=" vertical-align:top; "alt=" dpyaaaaaaaaa&bo=pwjaaqaaaaafefu! "/>
My condition is Stuname=gao the hint is null because the index is not created in Stuname
Indexing is a data structure that helps MySQL to get data in hilarious
B-tree B-Tree structure
650) this.width=650; "height=" 409 "src=" http://b288.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ y3kaddr24mohhy7vfhpbmuvplkx3humrkashheniajk!/b/dcabaaaaaaaa&bo=jwozaqaaaaafei8! "width=" 807 "style=" vertical-align:top; "alt=" dcabaaaaaaaa&bo=jwozaqaaaaafei8! "/>
Index reduces IO usage,
Create a silver lock need to look for high index value, relatively low no need to create, such as gender there is no index value to create, too many duplicate values

Index type
1, normal index
The most basic index, without any restrictions
2, unique index
A column value must be unique, but can be null
3, combined index
A composite index is a combination of multiple column values, but with a leftmost prefix, and you want to use a composite index, you must require that the leftmost value in the combined index is not used
4, full-text index
field types include char, varchar, text,
But for large data tables, generating a full-text index is a very time-consuming way of hard disk space
The index command uses
CREATE index IndexName on table name "which column" normal index
Create unique index indexname on table name "column value" uniquely indexed unique
CREATE index IndexName on table name "which column, which column, which column, which column" combination index
Create FULLTEXT index indexname on table name "which column" full-text index
--------------------------------------------------------------------------------------------------------
Check Index
Show index from table name;
Show keys from table name;
See what table names are in a table
--------------------------------------------------------------------------------------------------------------
Sometimes MySQL performance is reduced is the IO bottleneck, this has no way, sometimes can be resolved through the index, sometimes only to update the hardware configuration



This article is from the "11627223" blog, please be sure to keep this source http://11637223.blog.51cto.com/11627223/1911973

centos7-mysql-Index Optimization

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.