MySQL Hash index

Source: Internet
Author: User
Tags joins

When the big data Volume MyISAM engine table joins, MySQL only nest Loop way to operate, the efficiency is very low.

Therefore, the hash index should be used at this time.

Since only the memory and NDB engines support hash indexes, they should be used as cache tables.

For example:

CREATE temporary TABLE T1 engine=memory as SELECT * from TABLEA;

ALTER TABLE T1 ADD INDEX T1 (ID) USING HASH;

CREATE temporary TABLE T2 engine=memory as SELECT * from TABLEB;

ALTER TABLE T2 ADD INDEX T1 (ID) USING HASH;

select* from T1 INNER joins T2 on T1.id=t2.id.

DROP TABLE T1;

DROP TABLE T2;

The greater the amount of data, the more efficient the increase is.


MySQL Hash index

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.