MySQL index name How to use, when to use

Source: Internet
Author: User
Tags mysql index

Indexing is simple, what is this index name CID used when I write a MySQL statement?
Or is this CID only used when working with the index inside MySQL, and I don't use it when I write a statement?

Is it generally done to index it, and MySQL internally handles everything about the index? What else do I have to write myself?

Reply content:

Indexing is simple, what is this index name CID used when I write a MySQL statement?
Or is this CID only used when working with the index inside MySQL, and I don't use it when I write a statement?

Is it generally done to index it, and MySQL internally handles everything about the index? What else do I have to write myself?

    1. If you are concerned about whether an SQL query is indexed, you can EXPLAIN SELECT * FROM xxx WHERE yyy look at the query plan and it will tell you what index you are using, and here you will see your index name.

    2. There is also an occasion where you will use the index name, that is, if you want to force an index to query, you can use SELECT * FROM xxx FORCE INDEX yyy WHERE zzz , on the contrary, if you want to force ignore an index, you can use theSELECT * FROM xxx IGNORE INDEX yyy WHERE zzz

The differentiating function plays a differentiating function from the differentiating effect

First you need to understand what the index is, why the index can speed up the query, the index is to tell the data according to a certain collation of the data according to the index given rules, such as a union A,b,c index, he will be the data according to a B C code, when a query quotations such as SELECT * From TB1 where a=1 and b=2 order by C so MySQL will first use the A field to quickly locate the data on the disk, when the B data is ordered in accordance with the rules of a, so you can quickly locate the data range, the last C field is also ordered, So it can play a very good role, if there is no straight bottom is such, MySQL will go to the data on the disk to take a row and then the condition does not conform to the discard, and finally in accordance with the collation of the file sort, simply of course not only these, but also MySQL clustered index, index coverage, MyISAM InnoDB index rules, MyISAM index leaves do not directly store data, but instead point to a reference to a physical row, and InnoDB data is a reference to the primary key primary key, if not explicitly indicated primary Key. The system automatically generates an implicit primary key so that it simply points to the primary key reference, suggesting that the system learns

  • Related Article

    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.