Mysql_ Prefix Index _ Build

Source: Internet
Author: User
Tags unique id

--Check the frequency of occurrence
Select COUNT (*) as Cnt,city
From Sakila.city_demo GROUP by city ORDER by CNT DESC LIMIT 10;

1.select count (Distinct city)/count (*) from Sakila.city_demo;

* Selection of complete columns

2. Select COUNT (distinct left (city,3))/count (*) as SEL3,
COUNT (distinct left (city,4))/count (*) as SEL4,
COUNT (distinct left (city,5))/count (*) as SEL5,
COUNT (distinct left (city,6))/count (*) as SEL6,
COUNT (distinct left (city,7))/count (*) as Sel7

From Sakila.city_demo;

* The closer the prefix output is to the 1 output, the higher the performance

3. ALTER TABLE Sakilal.city_demo add key (city (7));

Usage scenarios:

The 16 binary unique ID uses the prefix index. Typically uses the first 8 bits, which significantly improves performance

Mysql_ Prefix Index _ Build

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.